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
Creates a new PdfBitmapConfig object with all settings initialized with their default values.
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.
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.
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.
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.
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.
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().
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().
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().
Specifies that the final pixel width of the PdfPage will not exceed the given maximum.
Specifies that the final pixel height of the PdfPage will not exceed the given maximum.
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.
pub 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.
pub 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.
Sets the pixel format that will be used during rendering of the PdfPage. The default is PdfBitmapFormat::BGRA.
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.
Controls whether user-supplied annotations should be included during rendering of
the PdfPage. The default is true.
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).
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.
Controls whether rendering output should be grayscale rather than full color.
The default is false.
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.
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.
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.
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.
Controls whether rendered images should be anti-aliased.
The default is true.
Controls whether rendered vector paths should be anti-aliased.
The default is true.
Controls whether the byte order of generated image data should be reversed
during rendering. The default is false. There should generally be no need
to set this flag, unless you want to do raw image processing and specifically
need the byte data returned by crate::bitmap::PdfBitmap::as_bytes() to be reversed.
Controls whether rendered vector fill paths need to be stroked.
The default is false.
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.
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.
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.
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.
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.
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.
pub 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.