Struct pdfium_render::page::PdfPage
source · [−]pub struct PdfPage<'a> { /* private fields */ }Expand description
A single page in a PdfDocument.
In addition to its own intrinsic properties, a PdfPage serves as the entry point to all object collections related to a single page in a document. These collections include:
- PdfPage::annotations(), all the user annotations attached to the PdfPage.
- PdfPage::boundaries(), all the boundary boxes relating to the PdfPage.
- PdfPage::objects(), all the displayable objects on the PdfPage.
Implementations
sourceimpl<'a> PdfPage<'a>
impl<'a> PdfPage<'a>
sourcepub fn width(&self) -> PdfPoints
pub fn width(&self) -> PdfPoints
Returns the width of this PdfPage in device-independent points. One point is 1/72 inches, roughly 0.358 mm.
sourcepub fn height(&self) -> PdfPoints
pub fn height(&self) -> PdfPoints
Returns the height of this PdfPage in device-independent points. One point is 1/72 inches, roughly 0.358 mm.
sourcepub fn orientation(&self) -> PdfPageOrientation
pub fn orientation(&self) -> PdfPageOrientation
Returns PdfPageOrientation::Landscape if the width of this PdfPage is greater than its height; otherwise returns PdfPageOrientation::Portrait.
sourcepub fn is_portrait(&self) -> bool
pub fn is_portrait(&self) -> bool
Returns true if this PdfPage has orientation PdfPageOrientation::Portrait.
sourcepub fn is_landscape(&self) -> bool
pub fn is_landscape(&self) -> bool
Returns true if this PdfPage has orientation PdfPageOrientation::Landscape.
sourcepub fn rotation(&self) -> Result<PdfBitmapRotation, PdfiumError>
pub fn rotation(&self) -> Result<PdfBitmapRotation, PdfiumError>
Returns any intrinsic rotation encoded into this document indicating a rotation should be applied to this PdfPage during rendering.
sourcepub fn set_rotation(&mut self, rotation: PdfBitmapRotation)
pub fn set_rotation(&mut self, rotation: PdfBitmapRotation)
Sets the intrinsic rotation that should be applied to this PdfPage during rendering.
sourcepub fn has_transparency(&self) -> bool
pub fn has_transparency(&self) -> bool
Returns true if any object on the page contains transparency.
sourcepub fn boundaries(&self) -> PdfPageBoundaries<'_>
pub fn boundaries(&self) -> PdfPageBoundaries<'_>
Returns the collection of bounding boxes defining the extents of this PdfPage.
sourcepub fn paper_size(&self) -> PdfPagePaperSize
pub fn paper_size(&self) -> PdfPagePaperSize
Returns the paper size of this PdfPage.
sourcepub fn text(&self) -> Result<PdfPageText<'_>, PdfiumError>
pub fn text(&self) -> Result<PdfPageText<'_>, PdfiumError>
Returns the collection of text boxes contained within this PdfPage.
sourcepub fn objects(&self) -> &PdfPageObjects<'_>
pub fn objects(&self) -> &PdfPageObjects<'_>
Returns an immutable collection of all the page objects on this PdfPage.
sourcepub fn objects_mut(&mut self) -> &mut PdfPageObjects<'a>
pub fn objects_mut(&mut self) -> &mut PdfPageObjects<'a>
Returns a mutable collection of all the page objects on this PdfPage.
sourcepub fn annotations(&self) -> &PdfPageAnnotations<'_>
pub fn annotations(&self) -> &PdfPageAnnotations<'_>
Returns an immutable collection of the annotations that have been added to this PdfPage.
sourcepub fn get_bitmap_with_config(
&self,
config: &PdfBitmapConfig
) -> Result<PdfBitmap<'_>, PdfiumError>
pub fn get_bitmap_with_config(
&self,
config: &PdfBitmapConfig
) -> Result<PdfBitmap<'_>, PdfiumError>
Returns a PdfBitmap using pixel dimensions, rotation settings, and rendering options configured in the given PdfBitmapConfig.
See also PdfPage::get_bitmap(), which directly creates a PdfBitmap object from this page using caller-specified pixel dimensions and page rotation settings.
sourcepub fn get_bitmap(
&self,
width: u16,
height: u16,
rotation: Option<PdfBitmapRotation>
) -> Result<PdfBitmap<'_>, PdfiumError>
pub fn get_bitmap(
&self,
width: u16,
height: u16,
rotation: Option<PdfBitmapRotation>
) -> Result<PdfBitmap<'_>, PdfiumError>
Returns a PdfBitmap with the given pixel dimensions and render-time rotation for this PdfPage containing the rendered content of this PdfPage.
It is the responsibility of the caller to ensure the given pixel width and height correctly maintain the page’s aspect ratio.
See also PdfPage::get_bitmap_with_config(), which calculates the correct pixel dimensions, rotation settings, and rendering options to apply from a PdfBitmapConfig object.
sourcepub fn flatten(&mut self) -> Result<(), PdfiumError>
pub fn flatten(&mut self) -> Result<(), PdfiumError>
Flattens all annotations and form fields on this PdfPage into the page contents.
sourcepub fn content_regeneration_strategy(
&self
) -> PdfPageContentRegenerationStrategy
pub fn content_regeneration_strategy(
&self
) -> PdfPageContentRegenerationStrategy
Returns the strategy used by pdfium-render to regenerate the content of a PdfPage.
Updates to a PdfPage are not committed to the underlying PdfDocument until the page’s content is regenerated. If a page is reloaded or closed without regenerating the page’s content, any changes not applied are lost.
By default, pdfium-render will trigger content regeneration on any change to a PdfPage;
this removes the possibility of data loss, and ensures changes can be read back from other
data structures as soon as they are made. However, if many changes are made to a page at once,
then regenerating the content after every change is inefficient; it is faster to stage
all changes first, then regenerate the page’s content just once. In this case,
changing the content regeneration strategy for a PdfPage can improve performance,
but you must be careful not to forget to commit your changes before closing
or reloading the page.
sourcepub fn set_content_regeneration_strategy(
&mut self,
strategy: PdfPageContentRegenerationStrategy
)
pub fn set_content_regeneration_strategy(
&mut self,
strategy: PdfPageContentRegenerationStrategy
)
Sets the strategy used by pdfium-render to regenerate the content of a PdfPage.
Updates to a PdfPage are not committed to the underlying PdfDocument until the page’s content is regenerated. If a page is reloaded or closed without regenerating the page’s content, any changes not applied are lost.
By default, pdfium-render will trigger content regeneration on any change to a PdfPage;
this removes the possibility of data loss, and ensures changes can be read back from other
data structures as soon as they are made. However, if many changes are made to a page at once,
then regenerating the content after every change is inefficient; it is faster to stage
all changes first, then regenerate the page’s content just once. In this case,
changing the content regeneration strategy for a PdfPage can improve performance,
but you must be careful not to forget to commit your changes before closing
or reloading the page.
sourcepub fn regenerate_content(&mut self) -> Result<(), PdfiumError>
pub fn regenerate_content(&mut self) -> Result<(), PdfiumError>
Commits any staged but unsaved changes to this PdfPage to the underlying PdfDocument.
Updates to a PdfPage are not committed to the underlying PdfDocument until the page’s content is regenerated. If a page is reloaded or closed without regenerating the page’s content, any changes not applied are lost.
By default, pdfium-render will trigger content regeneration on any change to a PdfPage;
this removes the possibility of data loss, and ensures changes can be read back from other
data structures as soon as they are made. However, if many changes are made to a page at once,
then regenerating the content after every change is inefficient; it is faster to stage
all changes first, then regenerate the page’s content just once. In this case,
changing the content regeneration strategy for a PdfPage can improve performance,
but you must be careful not to forget to commit your changes before closing
or reloading the page.
Trait Implementations
Auto Trait Implementations
impl<'a> !RefUnwindSafe for PdfPage<'a>
impl<'a> !Send for PdfPage<'a>
impl<'a> !Sync for PdfPage<'a>
impl<'a> Unpin for PdfPage<'a>
impl<'a> !UnwindSafe for PdfPage<'a>
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