{"id":13508947,"url":"https://github.com/bitcrowd/chromic_pdf","last_synced_at":"2025-03-30T11:33:04.775Z","repository":{"id":38108903,"uuid":"238210487","full_name":"bitcrowd/chromic_pdf","owner":"bitcrowd","description":"Convenient HTML to PDF/A rendering library for Elixir based on Chrome \u0026 Ghostscript","archived":false,"fork":false,"pushed_at":"2025-03-04T15:19:52.000Z","size":4367,"stargazers_count":442,"open_issues_count":13,"forks_count":40,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-03-25T11:50:19.926Z","etag":null,"topics":["chrome-devtools","chrome-headless","invoice","pdf","pdf-converter","pdf-generation"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitcrowd.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-04T13:17:37.000Z","updated_at":"2025-03-23T01:17:38.000Z","dependencies_parsed_at":"2023-12-17T20:45:11.734Z","dependency_job_id":"80dcede6-d410-4392-ad90-52144536098e","html_url":"https://github.com/bitcrowd/chromic_pdf","commit_stats":{"total_commits":206,"total_committers":17,"mean_commits":"12.117647058823529","dds":"0.25728155339805825","last_synced_commit":"9676c1244ab6f79662f2579d3de1272af79f9097"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitcrowd%2Fchromic_pdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitcrowd%2Fchromic_pdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitcrowd%2Fchromic_pdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitcrowd%2Fchromic_pdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitcrowd","download_url":"https://codeload.github.com/bitcrowd/chromic_pdf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246314044,"owners_count":20757455,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chrome-devtools","chrome-headless","invoice","pdf","pdf-converter","pdf-generation"],"created_at":"2024-08-01T02:01:00.824Z","updated_at":"2025-03-30T11:33:04.253Z","avatar_url":"https://github.com/bitcrowd.png","language":"Elixir","funding_links":[],"categories":["PDF","Uncategorized"],"sub_categories":["Uncategorized"],"readme":"![](assets/logo.svg)\n\n[![CircleCI](https://circleci.com/gh/bitcrowd/chromic_pdf.svg?style=shield)](https://circleci.com/gh/bitcrowd/chromic_pdf)\n[![Module Version](https://img.shields.io/hexpm/v/chromic_pdf.svg)](https://hex.pm/packages/chromic_pdf)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/chromic_pdf/)\n[![Total Download](https://img.shields.io/hexpm/dt/chromic_pdf.svg)](https://hex.pm/packages/chromic_pdf)\n[![License](https://img.shields.io/hexpm/l/chromic_pdf.svg)](https://github.com/bitcrowd/chromic_pdf/blob/master/LICENSE)\n[![Last Updated](https://img.shields.io/github/last-commit/bitcrowd/chromic_pdf.svg)](https://github.com/bitcrowd/chromic_pdf/commits/master)\n\nChromicPDF is a HTML-to-PDF renderer for Elixir, based on headless Chrome.\n\n## Features\n\n* **Node-free**: In contrast to [many other](https://hex.pm/packages?search=pdf\u0026sort=recent_downloads) packages, it does not use [puppeteer](https://github.com/puppeteer/puppeteer), and hence does not require Node.js. It communicates directly with Chrome's [DevTools API](https://chromedevtools.github.io/devtools-protocol/) over pipes, offering the same performance as puppeteer, if not better.\n* **Header/Footer**: Using the DevTools API allows to apply the full set of options of the [`printToPDF`](https://chromedevtools.github.io/devtools-protocol/tot/Page#method-printToPDF) function. Most notably, it supports header and footer HTML templates.\n* **PDF/A**: It can convert printed files to PDF/A using Ghostscript. Converted files pass the [verapdf](https://verapdf.org/) validator.\n\n## Requirements\n\n- Chromium or Chrome\n- Ghostscript (optional, for PDF/A support and concatenation of multiple sources)\n\nChromicPDF is tested in the following configurations:\n\n| Elixir | Erlang/OTP | Distribution    | Chromium        | Ghostscript |\n| ------ | ---------- | --------------- | --------------- | ----------- |\n| 1.15.7 | 26.2       | Alpine 3.18     | 119.0.6045.159  | 10.02.0     |\n| 1.14.5 | 25.3.1     | Alpine 3.17     | 112.0.5615.165  | 10.01.1     |\n| 1.14.0 | 25.1       | Debian Buster   | 90.0.4430.212-1 | 9.27        |\n| 1.11.4 | 22.3.4.26  | Debian Buster   | 90.0.4430.212-1 | 9.27        |\n\n## Installation\n\nChromicPDF is a supervision tree (rather than an application). You will need to inject it into the supervision tree of your application. First, add ChromicPDF to your runtime dependencies:\n\n```elixir\ndef deps do\n  [\n    {:chromic_pdf, \"~\u003e 1.17\"}\n  ]\nend\n```\n\nNext, start ChromicPDF as part of your application:\n\n```elixir\n# lib/my_app/application.ex\ndef MyApp.Application do\n  def start(_type, _args) do\n    children = [\n      # other apps...\n      ChromicPDF\n    ]\n\n    Supervisor.start_link(children, strategy: :one_for_one, name: MyApp.Supervisor)\n  end\nend\n```\n\n## Usage\n\n### Main API\n\nHere's how you generate a PDF from an external URL and store it in the local filesystem.\n\n```elixir\n# Prints a local HTML file to PDF.\nChromicPDF.print_to_pdf({:url, \"https://example.net\"}, output: \"example.pdf\")\n```\n\nThe next example shows how to print a local HTML file to PDF/A, as well as the use of a callback\nfunction that receives the generated PDF as path to a temporary file.\n\n```elixir\nChromicPDF.print_to_pdfa({:url, \"file:///example.html\"}, output: fn pdf -\u003e\n  # Send pdf via mail, upload to S3, ...\nend)\n```\n\n### Template API\n\n[ChromicPDF.Template](https://hexdocs.pm/chromic_pdf/ChromicPDF.Template.html) contains\nadditional functionality for controlling page dimensions of your PDF.\n\n```elixir\n[content: \"\u003cp\u003eHello Template\u003c/p\u003e\", size: :a4]\n|\u003e ChromicPDF.Template.source_and_options()\n|\u003e ChromicPDF.print_to_pdf()\n```\n\n### Multiple sources\n\nMultiple sources can be automatically concatenated using Ghostscript.\n\n```elixir\nChromicPDF.print_to_pdf([{:html, \"page 1\"}, {:html, \"page 2\"}], output: \"joined.pdf\")\n```\n\n### Examples\n\n* There is an outdated example of how to integrate ChromicPDF in a Phoenix application, see [examples/phoenix](https://github.com/bitcrowd/chromic_pdf/tree/v1.14.0/examples/phoenix).\n\n## Development\n\nThis should get you started:\n\n```\nmix deps.get\nmix test\n```\n\nFor running the full suite of integration tests, please install and have in your `$PATH`:\n\n* [`verapdf`](https://verapdf.org/)\n* For `pdfinfo` and `pdftotext`, you need `poppler-utils` (most Linux distributions) or [Xpdf](https://www.xpdfreader.com/) (OSX)\n* For the odd ZUGFeRD test in [`zugferd_test.exs`](https://github.com/bitcrowd/chromic_pdf/tree/main/test/integration/zugferd_test.exs), you need to download [ZUV](https://github.com/ZUGFeRD/ZUV) and set the `$ZUV_JAR` environment variable.\n\n## Acknowledgements\n\n* The PDF/A conversion is inspired by the `pdf2archive` script originally created by [@matteosecli](https://github.com/matteosecli/pdf2archive) and later enhanced by [@JaimeChavarriaga](https://github.com/JaimeChavarriaga/pdf2archive/tree/feature/support_pdf2b).\n\n## Copyright and License\n\nCopyright (c) 2019–2023 Bitcrowd GmbH\n\nLicensed under the Apache License 2.0. See [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitcrowd%2Fchromic_pdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitcrowd%2Fchromic_pdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitcrowd%2Fchromic_pdf/lists"}