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: u32Output width in pixels.
height: u32Output height in pixels.
background: RgbaColorBackground 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: u32Page 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: boolConvert the output to grayscale after rendering. Default: false.
antialiasing: boolEnable anti-aliasing for path rendering. Default: true.
text_antialiasing: boolAnti-aliasing for text rendering (default: true).
When false, text glyph outlines are rendered without anti-aliasing.
Corresponds to upstream bNoTextSmooth (inverted).
path_antialiasing: boolAnti-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: boolAnti-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
impl RenderConfig
Sourcepub fn with_background(self, bg: RgbaColor) -> Self
pub fn with_background(self, bg: RgbaColor) -> Self
Set the background color.
Sourcepub fn with_media_box(self, media_box: Rect) -> Self
pub fn with_media_box(self, media_box: Rect) -> Self
Set the page media box for coordinate transformation.
Sourcepub fn with_rotation(self, rotation: u32) -> Self
pub fn with_rotation(self, rotation: u32) -> Self
Set the page rotation in degrees (0, 90, 180, or 270).
Sourcepub fn with_tile_size(self, size: u32) -> Self
pub fn with_tile_size(self, size: u32) -> Self
Set the tile size in pixels for progressive rendering.
Sourcepub fn with_progress(self, progress: Arc<dyn RenderProgress>) -> Self
pub fn with_progress(self, progress: Arc<dyn RenderProgress>) -> Self
Set the progress callback for tile-based rendering.
Sourcepub fn with_grayscale(self, grayscale: bool) -> Self
pub fn with_grayscale(self, grayscale: bool) -> Self
Enable or disable grayscale output conversion.
Sourcepub fn with_antialiasing(self, antialiasing: bool) -> Self
pub fn with_antialiasing(self, antialiasing: bool) -> Self
Enable or disable anti-aliasing.
Sourcepub fn with_text_antialiasing(self, aa: bool) -> Self
pub fn with_text_antialiasing(self, aa: bool) -> Self
Enable or disable anti-aliasing specifically for text rendering.
Sourcepub fn with_path_antialiasing(self, aa: bool) -> Self
pub fn with_path_antialiasing(self, aa: bool) -> Self
Enable or disable anti-aliasing specifically for path/vector rendering.
Sourcepub fn with_image_antialiasing(self, aa: bool) -> Self
pub fn with_image_antialiasing(self, aa: bool) -> Self
Enable or disable anti-aliasing specifically for image scaling.
Sourcepub fn with_transform(self, matrix: Matrix) -> Self
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.
Sourcepub fn with_clip(self, rect: Rect) -> Self
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.
Sourcepub fn with_forced_colors(self, text: RgbaColor, background: RgbaColor) -> Self
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
impl Clone for RenderConfig
Source§fn clone(&self) -> RenderConfig
fn clone(&self) -> RenderConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more