pub struct PdfiumPage { /* private fields */ }Expand description
Rust interface to FPDF_PAGE
Implementations§
Source§impl PdfiumPage
impl PdfiumPage
pub fn boundaries(&self) -> PdfiumPageBoundaries<'_>
Sourcepub fn render_with_matrix(
&self,
width: i32,
height: i32,
format: PdfiumBitmapFormat,
background: Option<PdfiumColor>,
matrix: &PdfiumMatrix,
render_flags: i32,
clipping: Option<PdfiumRect>,
) -> PdfiumResult<PdfiumBitmap>
pub fn render_with_matrix( &self, width: i32, height: i32, format: PdfiumBitmapFormat, background: Option<PdfiumColor>, matrix: &PdfiumMatrix, render_flags: i32, clipping: Option<PdfiumRect>, ) -> PdfiumResult<PdfiumBitmap>
Renders this PdfiumPage into a new PdfiumBitmap using a transformation matrix.
This function provides fine-grained control over the rendering process by allowing you to directly specify a transformation matrix, background color, render flags, and clipping rectangle. The transformation matrix can be used to apply scaling, rotation or translation transformations during rendering.
§Arguments
width- The width of the target bitmap in pixelsheight- The height of the target bitmap in pixelsformat- The pixel format for the target bitmapbackground- Optional background color to fill the bitmap before renderingmatrix- The transformation matrix to apply during renderingrender_flags- Flags controlling the rendering behavior (0 for most use cases)clipping- Optional clipping rectangle to restrict rendering to a specific area
§Returns
Returns a PdfiumBitmap containing the rendered page, or a PdfiumError if rendering fails.
§Examples
use pdfium::*;
fn page_to_bitmap(
document: &PdfiumDocument,
index: i32,
height: i32,
) -> PdfiumResult<PdfiumBitmap> {
let page = document.page(index)?;
let bounds = page.boundaries().media()?;
let zoom = height as f32 / bounds.height();
let width = (bounds.width() * zoom) as i32;
let matrix = PdfiumMatrix::new_scale(zoom);
page.render_with_matrix(
width,
height,
PdfiumBitmapFormat::Bgra,
Some(PdfiumColor::WHITE),
&matrix,
0,
None,
)
}Sourcepub fn render_into_bitmap_with_matrix(
&self,
bitmap: &mut PdfiumBitmap,
matrix: &PdfiumMatrix,
render_flags: i32,
clipping: Option<PdfiumRect>,
)
pub fn render_into_bitmap_with_matrix( &self, bitmap: &mut PdfiumBitmap, matrix: &PdfiumMatrix, render_flags: i32, clipping: Option<PdfiumRect>, )
Renders this PdfiumPage into the given PdfiumBitmap using a transformation matrix.
This function provides fine-grained control over the rendering process by allowing you to directly specify a transformation matrix, render flags, and clipping rectangle. The transformation matrix can be used to apply scaling, rotation or translation transformations during rendering.
§Arguments
bitmap- The target bitmap to render intomatrix- The transformation matrix to apply during renderingrender_flags- Flags controlling the rendering behavior (0 for most use cases)clipping- Optional clipping rectangle to restrict rendering to a specific area. If None, defaults to the full bitmap dimensions.
§Returns
Returns Ok(()) if rendering succeeds, or a PdfiumError if rendering fails.
Trait Implementations§
Source§impl Drop for PdfiumPage
impl Drop for PdfiumPage
Source§fn drop(&mut self)
fn drop(&mut self)
Closes this PdfiumPage, releasing held memory.
Source§impl From<&PdfiumPage> for FPDF_PAGE
impl From<&PdfiumPage> for FPDF_PAGE
Source§fn from(value: &PdfiumPage) -> Self
fn from(value: &PdfiumPage) -> Self
Auto Trait Implementations§
impl Freeze for PdfiumPage
impl RefUnwindSafe for PdfiumPage
impl !Send for PdfiumPage
impl !Sync for PdfiumPage
impl Unpin for PdfiumPage
impl UnwindSafe for PdfiumPage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more