All Projects → bitcrowd → chromic_pdf

bitcrowd / chromic_pdf

Licence: Apache-2.0 license
Convenient HTML to PDF/A rendering library for Elixir based on Chrome & Ghostscript

Programming Languages

elixir
2628 projects
HTML
75241 projects

Projects that are alternatives of or similar to chromic pdf

Laravel Pdf
A Simple package for easily generating PDF documents from HTML. This package is specially for laravel but you can use this without laravel.
Stars: ✭ 79 (-59.69%)
Mutual labels:  pdf-converter, pdf-generation
pdftron-android-samples
PDFTron Android Samples
Stars: ✭ 30 (-84.69%)
Mutual labels:  pdf-converter, pdf-generation
Ptext Release
pText is a library for reading, creating and manipulating PDF files in python.
Stars: ✭ 124 (-36.73%)
Mutual labels:  pdf-converter, pdf-generation
Invoice printer
Super simple PDF invoicing
Stars: ✭ 644 (+228.57%)
Mutual labels:  invoice, pdf-generation
Crrri
A Chrome Remote Interface written in R
Stars: ✭ 137 (-30.1%)
Mutual labels:  chrome-devtools, chrome-headless
Pdfsave
Convert websites into readable PDFs
Stars: ✭ 46 (-76.53%)
Mutual labels:  pdf-converter, pdf-generation
Aws Lambda Libreoffice
85 MB LibreOffice to fit inside AWS Lambda compressed with Brotli
Stars: ✭ 145 (-26.02%)
Mutual labels:  pdf-converter, pdf-generation
pdf-creator-node
This package is used to generate HTML to PDF in Nodejs
Stars: ✭ 122 (-37.76%)
Mutual labels:  pdf-converter, pdf-generation
Chrome Devtools Java Client
Chrome DevTools java client.
Stars: ✭ 121 (-38.27%)
Mutual labels:  chrome-devtools, chrome-headless
Rod
A Devtools driver for web automation and scraping
Stars: ✭ 1,392 (+610.2%)
Mutual labels:  chrome-devtools, chrome-headless
Chrome Headless Render Pdf
Stars: ✭ 164 (-16.33%)
Mutual labels:  pdf-generation, chrome-headless
Cdp4j
cdp4j - Chrome DevTools Protocol for Java
Stars: ✭ 232 (+18.37%)
Mutual labels:  chrome-devtools, chrome-headless
Doctron
Docker-powered html convert to pdf(html2pdf), html to image(html2image like jpeg,png),which using chrome(golang) kernel, add watermarks to pdf, convert pdf to images etc.
Stars: ✭ 141 (-28.06%)
Mutual labels:  pdf-converter, pdf-generation
Go Stare
A fast & light web screenshot without headless browser but Chrome DevTools Protocol!
Stars: ✭ 87 (-55.61%)
Mutual labels:  chrome-devtools, chrome-headless
Rendora
dynamic server-side rendering using headless Chrome to effortlessly solve the SEO problem for modern javascript websites
Stars: ✭ 1,853 (+845.41%)
Mutual labels:  chrome-devtools, chrome-headless
Android-XML-to-PDF-Generator
This library is for convert XML to PDF very easily using Step Builders Pattern
Stars: ✭ 140 (-28.57%)
Mutual labels:  pdf-converter, pdf-generation
pdfio
PDFio is a simple C library for reading and writing PDF files.
Stars: ✭ 55 (-71.94%)
Mutual labels:  pdf-generation
devtools-proxy
Multiplexing proxy for Chrome DevTools. Fully compatible with Selenium and ChromeDriver
Stars: ✭ 64 (-67.35%)
Mutual labels:  chrome-devtools
laravel-print-api
Laravel package to access our print-api
Stars: ✭ 16 (-91.84%)
Mutual labels:  pdf-generation
carbone
Fast and simple report generator, from JSON to pdf, xslx, docx, odt...
Stars: ✭ 810 (+313.27%)
Mutual labels:  pdf-generation

CircleCI Module Version Hex Docs Total Download License Last Updated

ChromicPDF is a HTML-to-PDF renderer for Elixir, based on headless Chrome.

Features

  • Node-free: In contrast to many other packages, it does not use puppeteer, and hence does not require Node.js. It communicates directly with Chrome's DevTools API over pipes, offering the same performance as puppeteer, if not better.
  • Header/Footer: Using the DevTools API allows to apply the full set of options of the printToPDF function. Most notably, it supports header and footer HTML templates.
  • PDF/A: It can convert printed files to PDF/A using Ghostscript, inspired by the pdf2archive script originally created by @matteosecli and later enhanced by @JaimeChavarriaga. Created PDF/A-2b and PDF/A-3b files pass the verapdf compliance checks.

Requirements

  • Chromium or Chrome
  • Ghostscript (optional, for PDF/A support)

Installation

ChromicPDF 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:

def deps do
  [
    {:chromic_pdf, "~> 1.2"}
  ]
end

Next, start ChromicPDF as part of your application:

# lib/my_app/application.ex
def MyApp.Application do
  def start(_type, _args) do
    children = [
      # other apps...
      ChromicPDF
    ]

    Supervisor.start_link(children, strategy: :one_for_one, name: MyApp.Supervisor)
  end
end

Usage

Main API

Here's how you generate a PDF from an external URL and store it in the local filesystem.

# Prints a local HTML file to PDF.
ChromicPDF.print_to_pdf({:url, "https://example.net"}, output: "example.pdf")

The next example shows how to print a local HTML file to PDF/A, as well as the use of a callback function that receives the generated PDF as path to a temporary file.

ChromicPDF.print_to_pdfa({:url, "file:///example.html"}, output: fn pdf ->
  # Send pdf via mail, upload to S3, ...
end)

Template API

ChromicPDF.Template contains additional functionality that makes styling of PDF documents easier and overall provides a more convenient API. See the documentation for details.

[content: "<p>Hello Template</p>"]
|> ChromicPDF.Template.source_and_options()
|> ChromicPDF.print_to_pdf()

Examples

  • For a more complete example of how to integrate ChromicPDF in a Phoenix application, see examples/phoenix.

Development

For running the full suite of integration tests, please install and have in your $PATH:

  • verapdf
  • For pdfinfo and pdftotext, you need poppler-utils (most Linux distributions) or Xpdf (OSX)
  • For the odd ZUGFeRD test in zugferd_test.exs, you need to download ZUV and set the $ZUV_JAR environment variable.

Copyright and License

Copyright (c) 2019–2021 Bitcrowd GmbH

Licensed under the Apache License 2.0. See LICENSE file for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].