PDF Generator v0.2.2 PdfGenerator

PdfGenerator

Provides a simple wrapper around wkhtmltopdf and pdftk to generate possibly encrypted PDFs from an HTML source.

System requirements

  • wkhtmltopdf
  • pdftk (optional, for encrypted PDFs)
  • goon (optional, for Porcelain shalle wrapper)

Precompiled wkhtmltopdf binaries can be obtained here: http://wkhtmltopdf.org/downloads.html

pdftk should be available as package on your system via

  • apt-get install pdftk on Debian/Ubuntu
  • brew pdftk on OSX (you’ll need homebrew, of course)
  • Install the Exe-Installer on Windows found the project’s homepage (link above)

goon is available here: https://github.com/alco/goon/releases

Summary

Functions

Generates a pdf file from given html string. Returns a string containing a temporary file path for that PDF

Callback implementation for c::application.start/2

Functions

encrypt_pdf(pdf_input_path, user_pw, owner_pw)
generate(html)

Generates a pdf file from given html string. Returns a string containing a temporary file path for that PDF.

options:

  • page_size: output page size, defaults to “A4”
  • open_password: password required to open PDF. Will apply encryption to PDF
  • edit_password: password required to edit PDF
  • shell_params: list of command-line arguments to wkhtmltopdf see http://wkhtmltopdf.org/usage/wkhtmltopdf.txt for all options

Examples

pdf_path_1 = PdfGenerator.generate “

Boom

” pdf_path_2 = PdfGenerator.generate( “

Boom

”, page_size: “A5”, open_password: “secret”, edit_password: “g3h31m”, shell_params: [ "--outline", "--outline-depth3", "3" ] )

generate(html, options)
start(type, args)

Callback implementation for c::application.start/2.