pub struct WebOptions {Show 31 fields
pub trace_id: Option<String>,
pub single_page: Option<bool>,
pub paper_width: Option<LinearDimention>,
pub paper_height: Option<LinearDimention>,
pub margin_top: Option<LinearDimention>,
pub margin_bottom: Option<LinearDimention>,
pub margin_left: Option<LinearDimention>,
pub margin_right: Option<LinearDimention>,
pub prefer_css_page_size: Option<bool>,
pub generate_document_outline: Option<bool>,
pub print_background: Option<bool>,
pub omit_background: Option<bool>,
pub landscape: Option<bool>,
pub scale: Option<f64>,
pub native_page_ranges: Option<PageRange>,
pub header_html: Option<String>,
pub footer_html: Option<String>,
pub wait_delay: Option<Duration>,
pub wait_for_expression: Option<String>,
pub emulated_media_type: Option<MediaType>,
pub cookies: Option<Vec<Cookie>>,
pub skip_network_idle_events: Option<bool>,
pub user_agent: Option<String>,
pub extra_http_headers: Option<HashMap<String, String>>,
pub pdfa: Option<PDFFormat>,
pub pdfua: Option<bool>,
pub metadata: Option<HashMap<String, Value>>,
pub fail_on_http_status_codes: Option<Vec<u32>>,
pub fail_on_resource_http_status_codes: Option<Vec<u32>>,
pub fail_on_resource_loading_failed: Option<bool>,
pub fail_on_console_exceptions: Option<bool>,
}Expand description
Configuration for rendering PDF from web content using the Chromium engine.
Fields§
§trace_id: Option<String>By default, the API assigns a unique UUID trace to every request. However, you also have the option to specify the trace for each request.
This trace will show up on the end server as a Gotenberg-Trace header.
single_page: Option<bool>Define whether to print the entire content on one single page.
Default: false
paper_width: Option<LinearDimention>Specify paper width using units like 72pt, 96px, 1in, 25.4mm, 2.54cm, or 6pc.
Default: 8.5 (inches)
paper_height: Option<LinearDimention>Specify paper height using units like 72pt, 96px, 1in, 25.4mm, 2.54cm, or 6pc.
Default: 11 (inches)
margin_top: Option<LinearDimention>Specify top margin width using units like 72pt, 96px, 1in, 25.4mm, 2.54cm, or 6pc.
Default: 0.39 (inches)
margin_bottom: Option<LinearDimention>Specify bottom margin width using units like 72pt, 96px, 1in, 25.4mm, 2.54cm, or 6pc.
Default: 0.39 (inches)
margin_left: Option<LinearDimention>Specify left margin width using units like 72pt, 96px, 1in, 25.4mm, 2.54cm, or 6pc.
Default: 0.39 (inches)
margin_right: Option<LinearDimention>Specify right margin width using units like 72pt, 96px, 1in, 25.4mm, 2.54cm, or 6pc.
Default: 0.39 (inches)
prefer_css_page_size: Option<bool>Define whether to prefer page size as defined by CSS.
Default: false
generate_document_outline: Option<bool>Define whether the document outline should be embedded into the PDF.
Default: false
print_background: Option<bool>Print the background graphics.
Default: false
omit_background: Option<bool>Hide the default white background and allow generating PDFs with transparency.
Default: false
landscape: Option<bool>Set the page orientation to landscape.
Default: false
scale: Option<f64>The scale of the page rendering.
Default: 1.0
native_page_ranges: Option<PageRange>Page ranges to print, e.g., ‘1-5, 8, 11-13’ - empty means all pages.
Default: All pages
header_html: Option<String>HTML content containing the header.
The following classes allow you to inject printing values into the header: date - formatted print date. title - document title. url - document location. pageNumber - current page number. totalPages - total pages in the document.
Caveats: No JavaScript or external resources.
HTML content containing the footer.
The following classes allow you to inject printing values into the footer: date - formatted print date. title - document title. url - document location. pageNumber - current page number. totalPages - total pages in the document.
Caveats: No JavaScript or external resources.
wait_delay: Option<Duration>Duration to wait when loading an HTML document before converting it into PDF.
wait_for_expression: Option<String>The JavaScript expression to wait before converting an HTML document into PDF until it returns true.
For example:
# Somewhere in the HTML document.
var globalVar = 'notReady'
await promises()
window.globalVar = 'ready'request_options.wait_until = Some("window.globalVar === 'ready'".to_string());emulated_media_type: Option<MediaType>The media type to emulate, either “screen” or “print”. Default: “print”.
Cookies to store in the Chromium cookie jar
skip_network_idle_events: Option<bool>Do not wait for Chromium network to be idle. Default: true.
If you are having problems where the page is not fully rendered, try setting this to false.
user_agent: Option<String>Override the default User-Agent HTTP header.
extra_http_headers: Option<HashMap<String, String>>Extra HTTP headers to send by Chromium.
pdfa: Option<PDFFormat>Convert the resulting PDF into the given PDF/A format
pdfua: Option<bool>Enable PDF for Universal Access for optimal accessibility.
metadata: Option<HashMap<String, Value>>Write PDF metadata. Not all metadata are writable. Consider taking a look at https://exiftool.org/TagNames/XMP.html#pdf for an (exhaustive?) list of available metadata. Caution: Writing metadata may compromise PDF/A compliance.
fail_on_http_status_codes: Option<Vec<u32>>Fail on these HTTP status codes.
Fail a response if the HTTP status code from the main page is not acceptable.
An X99 entry means every HTTP status codes between X00 and X99 (e.g., 499 means every HTTP status codes between 400 and 499).
Default: [499,599] (all 4XX and 5XX status codes)
fail_on_resource_http_status_codes: Option<Vec<u32>>Fail on these HTTP status codes on resources. Fail a response if any of the resources loaded in the page have a status code that is not acceptable. An X99 entry means every HTTP status codes between X00 and X99 (e.g., 499 means every HTTP status codes between 400 and 499). Default: None
fail_on_resource_loading_failed: Option<bool>Fail a response if Chromium fails to load at least one resource. Default: false.
fail_on_console_exceptions: Option<bool>Fail a response if there are exceptions in the Chromium console.
Implementations§
Source§impl WebOptions
impl WebOptions
Sourcepub fn set_paper_format(&mut self, format: PaperFormat)
pub fn set_paper_format(&mut self, format: PaperFormat)
Set the paper format. If a custom paper size is needed, set the paper_width and paper_height fields manually.
Trait Implementations§
Source§impl Clone for WebOptions
impl Clone for WebOptions
Source§fn clone(&self) -> WebOptions
fn clone(&self) -> WebOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more