Skip to main content

RenderConfig

Struct RenderConfig 

Source
pub struct RenderConfig {
Show 15 fields pub width: u32, pub height: u32, pub background: RgbaColor, pub media_box: Option<Rect>, pub rotation: u32, pub tile_size: Option<u32>, pub progress: Option<Arc<dyn RenderProgress>>, pub grayscale: bool, pub antialiasing: bool, pub text_antialiasing: bool, pub path_antialiasing: bool, pub image_antialiasing: bool, pub custom_transform: Option<Matrix>, pub clip_rect: Option<Rect>, pub forced_color_scheme: Option<ColorScheme>,
}
Expand description

Configuration for rendering a page to a bitmap.

Fields§

§width: u32

Output width in pixels.

§height: u32

Output height in pixels.

§background: RgbaColor

Background color.

§media_box: Option<Rect>

Page media box in PDF user space units. When set, a page transform is computed to map PDF coordinates (bottom-left origin, Y up) to device coordinates (top-left origin, Y down), scaling to fit the requested width × height.

When None, an identity transform is used — PDF coordinates map directly to pixel coordinates without Y-flip or scaling.

§rotation: u32

Page rotation in degrees (0, 90, 180, or 270). Only used when media_box is Some.

Note: For rotated pages (90° or 270°), the caller is responsible for swapping width and height to match the rotated dimensions.

§tile_size: Option<u32>

Tile size in pixels for progressive rendering. None = render full page at once (default).

§progress: Option<Arc<dyn RenderProgress>>

Progress callback for tile-based rendering.

§grayscale: bool

Convert the output to grayscale after rendering. Default: false.

§antialiasing: bool

Enable anti-aliasing for path rendering. Default: true.

§text_antialiasing: bool

Anti-aliasing for text rendering (default: true). When false, text glyph outlines are rendered without anti-aliasing. Corresponds to upstream bNoTextSmooth (inverted).

§path_antialiasing: bool

Anti-aliasing for path/vector rendering (default: true). When false, path fills and strokes are rendered without anti-aliasing. Corresponds to upstream bNoPathSmooth (inverted).

§image_antialiasing: bool

Anti-aliasing for image scaling (default: true). When false, images are rendered with nearest-neighbor interpolation. Corresponds to upstream bNoImageSmooth (inverted).

§custom_transform: Option<Matrix>

Custom page transform matrix. When set, this overrides the matrix that would otherwise be computed from media_box and rotation.

Corresponds to the matrix parameter of FPDF_RenderPageBitmapWithMatrix.

§clip_rect: Option<Rect>

Device-space clip rectangle in pixel coordinates, where (0, 0) is the top-left corner of the bitmap, x increases rightward, and y increases downward. The Rect fields map as: left/right for the x range and bottom/top for the y range (both inclusive-exclusive). Pixels outside this rectangle are replaced by the background color after rendering. None (default) means the full width × height surface is used.

Corresponds to the clipping parameter of FPDF_RenderPageBitmapWithMatrix.

§forced_color_scheme: Option<ColorScheme>

If set, all fill/stroke colors are replaced with this scheme (accessibility mode). Corresponds to CPDF_RenderOptions::kForcedColor.

Implementations§

Source§

impl RenderConfig

Source

pub fn with_size(self, width: u32, height: u32) -> Self

Set the output dimensions in pixels.

Source

pub fn with_background(self, bg: RgbaColor) -> Self

Set the background color.

Source

pub fn with_media_box(self, media_box: Rect) -> Self

Set the page media box for coordinate transformation.

Source

pub fn with_rotation(self, rotation: u32) -> Self

Set the page rotation in degrees (0, 90, 180, or 270).

Source

pub fn with_tile_size(self, size: u32) -> Self

Set the tile size in pixels for progressive rendering.

Source

pub fn with_progress(self, progress: Arc<dyn RenderProgress>) -> Self

Set the progress callback for tile-based rendering.

Source

pub fn with_grayscale(self, grayscale: bool) -> Self

Enable or disable grayscale output conversion.

Source

pub fn with_antialiasing(self, antialiasing: bool) -> Self

Enable or disable anti-aliasing.

Source

pub fn with_text_antialiasing(self, aa: bool) -> Self

Enable or disable anti-aliasing specifically for text rendering.

Source

pub fn with_path_antialiasing(self, aa: bool) -> Self

Enable or disable anti-aliasing specifically for path/vector rendering.

Source

pub fn with_image_antialiasing(self, aa: bool) -> Self

Enable or disable anti-aliasing specifically for image scaling.

Source

pub fn with_transform(self, matrix: Matrix) -> Self

Set a custom page transform matrix, bypassing the media_box/rotation calculation.

The matrix maps PDF user-space coordinates to device pixel coordinates. When set, media_box and rotation are ignored.

Corresponds to FPDF_RenderPageBitmapWithMatrix.

Source

pub fn with_clip(self, rect: Rect) -> Self

Set a device-space clip rectangle.

Pixels outside rect are replaced with the background color after rendering. Coordinates are in device pixels with the top-left corner at (0, 0).

Corresponds to the clipping parameter of FPDF_RenderPageBitmapWithMatrix.

Source

pub fn with_forced_colors(self, text: RgbaColor, background: RgbaColor) -> Self

Enable forced color mode for accessibility rendering.

When set, all text, stroke, and fill colors are replaced with the specified colors. Image content is not affected.

Corresponds to CPDF_RenderOptions::kForcedColor.

Trait Implementations§

Source§

impl Clone for RenderConfig

Source§

fn clone(&self) -> RenderConfig

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 RenderConfig

Source§

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

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

impl Default for RenderConfig

Source§

fn default() -> Self

Returns the “default value” for a type. 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> Same for T

Source§

type Output = T

Should always be Self
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