gotenberg_pdf

Struct WebOptions

Source
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.

§footer_html: Option<String>

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: Option<Vec<Cookie>>

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

Source

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

Source§

fn clone(&self) -> WebOptions

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WebOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WebOptions

Source§

fn default() -> WebOptions

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for WebOptions

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for WebOptions

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T