ScreenshotOptions

Struct ScreenshotOptions 

Source
pub struct ScreenshotOptions {
Show 19 fields pub trace_id: Option<String>, pub width: Option<u32>, pub height: Option<u32>, pub clip: Option<bool>, pub format: Option<ImageFormat>, pub quality: Option<u8>, pub omit_background: Option<bool>, pub optimize_for_speed: Option<bool>, 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 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

Options for taking a screenshot of a webpage.

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.

§width: Option<u32>

The device screen width in pixels. Default: 800.

§height: Option<u32>

The device screen height in pixels. Default: 600.

§clip: Option<bool>

Define whether to clip the screenshot according to the device dimensions. Default: false.

§format: Option<ImageFormat>

The image format, either “png”, “jpeg” or “webp”. Default: png.

§quality: Option<u8>

The compression quality from range 0 to 100 (jpeg only). Default: 100.

§omit_background: Option<bool>

Hide the default white background and allow generating screenshots with transparency. Default: false.

§optimize_for_speed: Option<bool>

Define whether to optimize image encoding for speed, not for resulting size. Default: false.

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

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

Trait Implementations§

Source§

impl Clone for ScreenshotOptions

Source§

fn clone(&self) -> ScreenshotOptions

Returns a duplicate 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 ScreenshotOptions

Source§

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

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

impl Default for ScreenshotOptions

Source§

fn default() -> ScreenshotOptions

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

impl<'de> Deserialize<'de> for ScreenshotOptions

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 ScreenshotOptions

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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,