GotenbergElixir.Chromium (Gotenberg Elixir v0.1.1)

Copy Markdown View Source

Provides functions to convert URLs, HTML, and Markdown files into PDFs or screenshots.

Summary

Functions

Converts HTML file content into a PDF using Chromium.

Converts HTML file content into a screenshot using Chromium.

Converts Markdown files into a PDF using Chromium.

Converts Markdown files into a screenshot using Chromium.

Converts a URL into a PDF using Chromium.

Converts a URL into a screenshot using Chromium.

Types

console_exception_option()

@type console_exception_option() :: {:fail_on_console_exceptions, boolean()}

cookie()

@type cookie() :: %{
  name: String.t(),
  value: String.t(),
  domain: String.t(),
  path: String.t() | nil,
  secure: boolean() | nil,
  http_only: boolean() | nil,
  same_site: String.t() | nil
}

cookie_option()

@type cookie_option() :: {:cookies, [cookie()]}

custom_http_header_option()

@type custom_http_header_option() ::
  {:user_agent, String.t()} | {:extra_http_headers, map()}

files()

@type files() :: [{String.t(), binary()}]

flatten_option()

@type flatten_option() :: {:flatten, boolean()}

invalid_http_status_codes_option()

@type invalid_http_status_codes_option() ::
  {:fail_on_http_status_codes, [non_neg_integer()]}
  | {:fail_on_resource_http_status_codes, [non_neg_integer()]}

media_type_option()

@type media_type_option() :: {:emulate_media_type, String.t()}

metadata_option()

@type metadata_option() :: {:metadata, map()}

network_error_option()

@type network_error_option() :: {:fail_on_resource_loading_failed, boolean()}

page_property_option()

@type page_property_option() ::
  {:single_page, boolean()}
  | {:paper_width, float()}
  | {:paper_height, float()}
  | {:margin_top, float()}
  | {:margin_bottom, float()}
  | {:margin_left, float()}
  | {:margin_right, float()}
  | {:prefer_css_page_size, boolean()}
  | {:generate_document_outline, boolean()}
  | {:generate_tagged_pdf, boolean()}
  | {:print_background, boolean()}
  | {:omit_background, boolean()}
  | {:landscape, boolean()}
  | {:scale, float()}
  | {:native_page_ranges, String.t()}

pdf_option()

pdfa_pdfua_option()

@type pdfa_pdfua_option() :: {:pdfa, String.t()} | {:pdfua, boolean()}

performance_mode_option()

@type performance_mode_option() :: {:skip_network_idle_event, boolean()}

screenshot_option()

@type screenshot_option() ::
  {:width, non_neg_integer()}
  | {:height, non_neg_integer()}
  | {:clip, boolean()}
  | {:format, String.t()}
  | {:quality, non_neg_integer()}
  | {:omit_background, boolean()}
  | {:optimize_for_speed, boolean()}
  | wait_option()
  | media_type_option()
  | cookie_option()
  | custom_http_header_option()
  | invalid_http_status_codes_option()
  | console_exception_option()
  | performance_mode_option()

split_option()

@type split_option() ::
  {:split_mode, String.t()}
  | {:split_span, String.t()}
  | {:split_unify, boolean()}

wait_option()

@type wait_option() :: {:wait_delay, String.t()} | {:wait_for_expression, String.t()}

Functions

html_file_into_pdf(html, additional_files \\ [], options \\ [])

Converts HTML file content into a PDF using Chromium.

## Parameters

  • html: The HTML content as a binary string.
  • additional_files: A list of additional files (images, CSS, fonts) as {filename, file}
  • options: Optional parameters passed as a keyword list.

## Options For a list of all available options, refer to the official Gotenberg documentation.

html_file_into_screenshot(html, additional_files \\ [], options \\ [])

Converts HTML file content into a screenshot using Chromium.

## Parameters

  • html: The HTML content as a binary string.
  • additional_files: A list of additional files (images, CSS, fonts) as {filename, file}
  • options: Optional parameters passed as a keyword list.

## Options For a list of all available options, refer to the official Gotenberg documentation.

markdown_files_into_pdf(index_html, markdown_files, options \\ [])

Converts Markdown files into a PDF using Chromium.

## Parameters

  • index_html: The HTML template content that wraps the markdown (uses {{ toHTML "filename.md" }} syntax).
  • markdown_files: A list of markdown files as {filename, file}
  • options: Optional parameters passed as a keyword list.

## Options For a list of all available options, refer to the official Gotenberg documentation.

markdown_files_into_screenshot(index_html, markdown_files, options \\ [])

@spec markdown_files_into_screenshot(String.t(), files(), [screenshot_option()]) ::
  {:ok, GotenbergElixir.HttpClient.Behaviour.response()}
  | {:error, GotenbergElixir.HttpClient.Behaviour.error()}

Converts Markdown files into a screenshot using Chromium.

## Parameters

  • index_html: The HTML template content that wraps the markdown (uses {{ toHTML "filename.md" }} syntax).
  • markdown_files: A list of markdown files as {filename, file}
  • options: Optional parameters passed as a keyword list.

## Options For a list of all available options, refer to the official Gotenberg documentation.

url_into_pdf(url, options \\ [])

Converts a URL into a PDF using Chromium.

## Parameters

  • url: The URL to convert.
  • options: Optional parameters passed as a keyword list.

## Options For a list of all available options, refer to the official Gotenberg documentation.

url_into_screenshot(url, options \\ [])

Converts a URL into a screenshot using Chromium.

## Parameters

  • url: The URL to convert.
  • options: Optional parameters passed as a keyword list.

## Options For a list of all available options, refer to the official Gotenberg documentation.