Struct pdfium_render::bitmap_config::PdfBitmapConfig
source · [−]pub struct PdfBitmapConfig { /* private fields */ }Expand description
Configures the scaling, rotation, and rendering settings that should be applied to
a PdfPage to create a PdfBitmap for that page. PdfBitmapConfig can accommodate pages of
different sizes while correctly maintaining each page’s aspect ratio, automatically
rotate portrait or landscape pages, generate page thumbnails, and apply maximum and
minimum pixel sizes to the scaled width and height of the final bitmap.
Implementations
sourceimpl PdfBitmapConfig
impl PdfBitmapConfig
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new PdfBitmapConfig object with all settings initialized with their default values.
sourcepub fn thumbnail(self, size: u8) -> Self
pub fn thumbnail(self, size: u8) -> Self
Applies settings suitable for generating a thumbnail.
- The source PdfPage will be rendered with a maximum width and height of the given pixel size
- The page will not be rotated, irrespective of its orientation
- Image quality settings will be reduced to improve performance
- Annotations and user-filled form field data will not be rendered.
These settings are applied to this PdfBitmapConfig object immediately and can be selectively overridden by later function calls. For instance, a later call to PdfBitmapConfig::rotate() can specify a custom rotation setting that will apply to the thumbnail.
sourcepub fn set_target_size(self, width: u16, height: u16) -> Self
pub fn set_target_size(self, width: u16, height: u16) -> Self
Converts the width and height of a PdfPage from points to pixels, scaling each dimension to the given target pixel sizes. The aspect ratio of the source page will not be maintained.
sourcepub fn set_target_width(self, width: u16) -> Self
pub fn set_target_width(self, width: u16) -> Self
Converts the width of a PdfPage from points to pixels, scaling the source page width to the given target pixel width. The aspect ratio of the source page will be maintained so long as there is no call to PdfBitmapConfig::set_target_size() or PdfBitmapConfig::set_target_height() that overrides it.
sourcepub fn set_target_height(self, height: u16) -> Self
pub fn set_target_height(self, height: u16) -> Self
Converts the height of a PdfPage from points to pixels, scaling the source page height to the given target pixel height. The aspect ratio of the source page will be maintained so long as there is no call to PdfBitmapConfig::set_target_size() or PdfBitmapConfig::set_target_width() that overrides it.
sourcepub fn scale_page_to_display_size(self, width: u16, height: u16) -> Self
pub fn scale_page_to_display_size(self, width: u16, height: u16) -> Self
Applies settings to this PdfBitmapConfig suitable for filling the given screen display size.
The source page’s dimensions will be scaled so that both width and height attempt to fill, but do not exceed, the given pixel dimensions. The aspect ratio of the source page will be maintained. Landscape pages will be automatically rotated by 90 degrees and will be scaled down if necessary to fit the display width.
sourcepub fn scale_page_by_factor(self, scale: f32) -> Self
pub fn scale_page_by_factor(self, scale: f32) -> Self
Converts the width and height of a PdfPage from points to pixels by applying the given scale factor to both dimensions. The aspect ratio of the source page will be maintained. Overrides any previous call to PdfBitmapConfig::scale_page_by_factor(), PdfBitmapConfig::scale_page_width_by_factor(), or PdfBitmapConfig::scale_page_height_by_factor().
sourcepub fn scale_page_width_by_factor(self, scale: f32) -> Self
pub fn scale_page_width_by_factor(self, scale: f32) -> Self
Converts the width of the PdfPage from points to pixels by applying the given scale factor. The aspect ratio of the source page will not be maintained if a different scale factor is applied to the height. Overrides any previous call to PdfBitmapConfig::scale_page_by_factor(), PdfBitmapConfig::scale_page_width_by_factor(), or PdfBitmapConfig::scale_page_height_by_factor().
sourcepub fn scale_page_height_by_factor(self, scale: f32) -> Self
pub fn scale_page_height_by_factor(self, scale: f32) -> Self
Converts the height of the PdfPage from points to pixels by applying the given scale factor. The aspect ratio of the source page will not be maintained if a different scale factor is applied to the width. Overrides any previous call to PdfBitmapConfig::scale_page_by_factor(), PdfBitmapConfig::scale_page_width_by_factor(), or PdfBitmapConfig::scale_page_height_by_factor().
sourcepub fn set_maximum_width(self, width: u16) -> Self
pub fn set_maximum_width(self, width: u16) -> Self
Specifies that the final pixel width of the PdfPage will not exceed the given maximum.
sourcepub fn set_maximum_height(self, height: u16) -> Self
pub fn set_maximum_height(self, height: u16) -> Self
Specifies that the final pixel height of the PdfPage will not exceed the given maximum.
sourcepub fn rotate(
self,
rotation: PdfBitmapRotation,
do_rotate_constraints: bool
) -> Self
pub fn rotate(
self,
rotation: PdfBitmapRotation,
do_rotate_constraints: bool
) -> Self
Applies the given rotation setting to the PdfPage during rendering, irrespective
of its orientation. If the given flag is set to true then any maximum
constraint on the final pixel width set by a call to PdfBitmapConfig::set_maximum_width()
will be rotated so it becomes a constraint on the final pixel height, and any
maximum constraint on the final pixel height set by a call to PdfBitmapConfig::set_maximum_height()
will be rotated so it becomes a constraint on the final pixel width.
sourcepub fn rotate_if_portait(
self,
rotation: PdfBitmapRotation,
do_rotate_constraints: bool
) -> Self
pub fn rotate_if_portait(
self,
rotation: PdfBitmapRotation,
do_rotate_constraints: bool
) -> Self
Applies the given rotation settings to the PdfPage during rendering, if the page
is in portrait orientation. If the given flag is set to true and the given
rotation setting is PdfBitmapRotation::Degrees90 or PdfBitmapRotation::Degrees270
then any maximum constraint on the final pixel width set by a call to PdfBitmapConfig::set_maximum_width()
will be rotated so it becomes a constraint on the final pixel height and any
maximum constraint on the final pixel height set by a call to PdfBitmapConfig::set_maximum_height()
will be rotated so it becomes a constraint on the final pixel width.
sourcepub fn rotate_if_landscape(
self,
rotation: PdfBitmapRotation,
do_rotate_constraints: bool
) -> Self
pub fn rotate_if_landscape(
self,
rotation: PdfBitmapRotation,
do_rotate_constraints: bool
) -> Self
Applies the given rotation settings to the PdfPage during rendering, if the page
is in landscape orientation. If the given flag is set to true and the given
rotation setting is PdfBitmapRotation::Degrees90 or PdfBitmapRotation::Degrees270
then any maximum constraint on the final pixel width set by a call to PdfBitmapConfig::set_maximum_width()
will be rotated so it becomes a constraint on the final pixel height and any
maximum constraint on the final pixel height set by a call to PdfBitmapConfig::set_maximum_height()
will be rotated so it becomes a constraint on the final pixel width.
sourcepub fn set_format(self, format: PdfBitmapFormat) -> Self
pub fn set_format(self, format: PdfBitmapFormat) -> Self
Sets the pixel format that will be used during rendering of the PdfPage. The default is PdfBitmapFormat::BGRA.
sourcepub fn render_form_data(self, do_render: bool) -> Self
pub fn render_form_data(self, do_render: bool) -> Self
Controls whether form data widgets and user-supplied form data should be included
during rendering of the PdfPage. The default is true. The setting has no effect
if the PdfDocument containing the PdfPage does not include an embedded PdfForm.
sourcepub fn render_annotations(self, do_render: bool) -> Self
pub fn render_annotations(self, do_render: bool) -> Self
Controls whether user-supplied annotations should be included during rendering of
the PdfPage. The default is true.
sourcepub fn use_lcd_text_rendering(self, do_set_flag: bool) -> Self
pub fn use_lcd_text_rendering(self, do_set_flag: bool) -> Self
Controls whether text rendering should be optimized for LCD display.
The default is false.
Has no effect if anti-aliasing of text has been disabled by a call to
PdfBitmapConfig::set_text_smoothing(false).
sourcepub fn disable_native_text_rendering(self, do_set_flag: bool) -> Self
pub fn disable_native_text_rendering(self, do_set_flag: bool) -> Self
Controls whether platform text rendering should be disabled on platforms that support it.
The alternative is for Pdfium to render all text internally, which may give more
consistent rendering results across platforms but may also be slower.
The default is false.
sourcepub fn use_grayscale_rendering(self, do_set_flag: bool) -> Self
pub fn use_grayscale_rendering(self, do_set_flag: bool) -> Self
Controls whether rendering output should be grayscale rather than full color.
The default is false.
sourcepub fn limit_render_image_cache_size(self, do_set_flag: bool) -> Self
pub fn limit_render_image_cache_size(self, do_set_flag: bool) -> Self
Controls whether Pdfium should limit its image cache size during rendering.
A smaller cache size may result in lower memory usage at the cost of slower rendering.
The default is false.
sourcepub fn force_half_tone(self, do_set_flag: bool) -> Self
pub fn force_half_tone(self, do_set_flag: bool) -> Self
Controls whether Pdfium should always use halftone for image stretching.
Halftone image stretching is often higher quality than linear image stretching
but is much slower. The default is false.
sourcepub fn use_print_quality(self, do_set_flag: bool) -> Self
pub fn use_print_quality(self, do_set_flag: bool) -> Self
Controls whether Pdfium should render for printing. The default is false.
Certain PDF files may stipulate different quality settings for on-screen display
compared to printing. For these files, changing this setting to true will result
in a higher quality rendered bitmap but slower performance. For PDF files that do
not stipulate different quality settings, changing this setting will have no effect.
sourcepub fn set_text_smoothing(self, do_set_flag: bool) -> Self
pub fn set_text_smoothing(self, do_set_flag: bool) -> Self
Controls whether rendered text should be anti-aliased.
The default is true.
The enabling of LCD-optimized text rendering via a call to
PdfiumBitmapConfig::use_lcd_text_rendering(true) has no effect if this flag
is set to false.
sourcepub fn set_image_smoothing(self, do_set_flag: bool) -> Self
pub fn set_image_smoothing(self, do_set_flag: bool) -> Self
Controls whether rendered images should be anti-aliased.
The default is true.
sourcepub fn set_path_smoothing(self, do_set_flag: bool) -> Self
pub fn set_path_smoothing(self, do_set_flag: bool) -> Self
Controls whether rendered vector paths should be anti-aliased.
The default is true.
sourcepub fn set_reverse_byte_order(self, do_set_flag: bool) -> Self
pub fn set_reverse_byte_order(self, do_set_flag: bool) -> Self
Controls whether the byte order of generated image data should be reversed
during rendering. The default is true, so that Pdfium returns pixel data as RGB8
rather than its default BGR8. There should generally be no need to change this flag,
unless you want to do raw image processing and specifically need the pixel data returned
by crate::bitmap::PdfBitmap::as_bytes() to be in BGR8 format.
sourcepub fn render_fills_as_strokes(self, do_set_flag: bool) -> Self
pub fn render_fills_as_strokes(self, do_set_flag: bool) -> Self
Controls whether rendered vector fill paths need to be stroked.
The default is false.
sourcepub fn highlight_all_form_fields(self, color: PdfColor) -> Self
pub fn highlight_all_form_fields(self, color: PdfColor) -> Self
Highlights all rendered form fields with the given color. Note that specifying a solid color with no opacity will overprint any user data in the field.
Highlights all rendered push button form fields with the given color. Note that specifying a solid color with no opacity will overprint any user data in the field.
sourcepub fn highlight_checkbox_form_fields(self, color: PdfColor) -> Self
pub fn highlight_checkbox_form_fields(self, color: PdfColor) -> Self
Highlights all rendered checkbox form fields with the given color. Note that specifying a solid color with no opacity will overprint any user data in the field.
Highlights all rendered radio button form fields with the given color. Note that specifying a solid color with no opacity will overprint any user data in the field.
sourcepub fn highlight_combobox_form_fields(self, color: PdfColor) -> Self
pub fn highlight_combobox_form_fields(self, color: PdfColor) -> Self
Highlights all rendered combobox form fields with the given color. Note that specifying a solid color with no opacity will overprint any user data in the field.
sourcepub fn highlight_listbox_form_fields(self, color: PdfColor) -> Self
pub fn highlight_listbox_form_fields(self, color: PdfColor) -> Self
Highlights all rendered listbox form fields with the given color. Note that specifying a solid color with no opacity will overprint any user data in the field.
sourcepub fn highlight_text_form_fields(self, color: PdfColor) -> Self
pub fn highlight_text_form_fields(self, color: PdfColor) -> Self
Highlights all rendered text entry form fields with the given color. Note that specifying a solid color with no opacity will overprint any user data in the field.
sourcepub fn highlight_signature_form_fields(self, color: PdfColor) -> Self
pub fn highlight_signature_form_fields(self, color: PdfColor) -> Self
Highlights all rendered signature form fields with the given color. Note that specifying a solid color with no opacity will overprint any user data in the field.
sourcepub fn highlight_form_fields_of_type(
self,
form_field_type: PdfFormFieldType,
color: PdfColor
) -> Self
pub fn highlight_form_fields_of_type(
self,
form_field_type: PdfFormFieldType,
color: PdfColor
) -> Self
Highlights all rendered form fields matching the given type with the given color. Note that specifying a solid color with no opacity will overprint any user data in the field.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for PdfBitmapConfig
impl Send for PdfBitmapConfig
impl Sync for PdfBitmapConfig
impl Unpin for PdfBitmapConfig
impl UnwindSafe for PdfBitmapConfig
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<R, P> ReadPrimitive<R> for P where
R: Read + ReadEndian<P>,
P: Default,
impl<R, P> ReadPrimitive<R> for P where
R: Read + ReadEndian<P>,
P: Default,
sourcefn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
sourcefn read_from_big_endian(read: &mut R) -> Result<Self, Error>
fn read_from_big_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
sourcefn read_from_native_endian(read: &mut R) -> Result<Self, Error>
fn read_from_native_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().