Puppeteer PDF v1.0.3 PuppeteerPdf.Generate View Source

Generate a PDF file from multiple available sources.

Link to this section Summary

Functions

Generate PDF file with an HTML file path given as input

Generate PDF file given an HTML string input

Link to this section Functions

Link to this function

from_file(html_file_path, pdf_output_path, options \\ []) View Source
from_file(String.t(), String.t(), list()) ::
  {:ok, String.t()} | {:error, atom()}

Generate PDF file with an HTML file path given as input.

Options

  • header_template - HTML template for the print header.
  • footer_template - HTML template for the print footer.
  • display_header_footer - Display header and footer.
  • format - Page format. Possible values: Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6
  • margin_left - Integer value (px)
  • margin_right - Integer value (px)
  • margin_top - Integer value (px)
  • margin_bottom - Integer value (px)
  • scale - Scale of the webpage rendering. (default: 1). Accept values between 0.1 and 2.
  • width - Paper width, accepts values labeled with units.
  • height - Paper height, accepts values labeled with units.
  • debug - Output Puppeteer PDF options
  • landscape - Paper orientation.
  • print_background - Print background graphics.
  • timeout - Integer value (ms), configures the timeout of the PDF creation (defaults to 5000)
  • wait_until - :load, :domcontentloaded, :networkidle0, :networkidle2
Link to this function

from_string(html_code, pdf_output_path, options \\ []) View Source
from_string(String.t(), String.t(), list()) ::
  {:ok, String.t()} | {:error, atom()}

Generate PDF file given an HTML string input

Options

  • header_template - HTML template for the print header.
  • footer_template - HTML template for the print footer.
  • display_header_footer - Display header and footer.
  • format - Page format. Possible values: Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6
  • margin_left - Integer value or string with one of the supported units (px, in, mm, cm)
  • margin_right - Integer value or string with one of the supported units (px, in, mm, cm)
  • margin_top - Integer value or string with one of the supported units (px, in, mm, cm)
  • margin_bottom - Integer value or string with one of the supported units (px, in, mm, cm)
  • scale - Scale of the webpage rendering. (default: 1). Accept values between 0.1 and 2.
  • width - Paper width, accepts values labeled with units.
  • height - Paper height, accepts values labeled with units.
  • debug - Output Puppeteer PDF options
  • landscape - Paper orientation.
  • print_background - Print background graphics.
  • timeout - Integer value (ms), configures the timeout of the PDF creation (defaults to 5000)