PuppeteerPdf.Generate (Puppeteer PDF v1.0.1)

View Source

Generate a PDF file from multiple available sources.

Summary

Functions

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

Generate PDF file given an HTML string input

Generate PDF file with a URL given as input.

Functions

from_file(html_file_path, pdf_output_path, options \\ [])

@spec 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)

from_string(html_code, pdf_output_path, options \\ [])

@spec 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 (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)

from_url(url, pdf_output_path, options \\ [])

@spec from_url(String.t(), String.t(), list()) :: {:ok, String.t()} | {:error, atom()}

Generate PDF file with a URL 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)