pub struct Page<'a> { /* private fields */ }
Expand description
A PDF page.
Implementations§
Source§impl<'a> Page<'a>
impl<'a> Page<'a>
Sourcepub fn page_stream(&self) -> Option<&[u8]>
pub fn page_stream(&self) -> Option<&[u8]>
Return the decoded content stream of the page.
Sourcepub fn intersected_crop_box(&self) -> Rect
pub fn intersected_crop_box(&self) -> Rect
Return the intersection of crop box and media box.
Sourcepub fn initial_transform(&self, invert_y: bool) -> Affine
pub fn initial_transform(&self, invert_y: bool) -> Affine
Return the initial transform that should be applied when rendering. This accounts for a number of factors, such as the mismatch between PDF’s y-up and most renderers’ y-down coordinate system, the rotation of the page and the offset of the crop box.
Sourcepub fn render_dimensions(&self) -> (f32, f32)
pub fn render_dimensions(&self) -> (f32, f32)
Return the with and height of the page that should be assumed when rendering the page.
Depending on the document, it is either based on the media box or the crop box of the page. In addition to that, it also takes the rotation of the page into account.
Sourcepub fn operations(&self) -> UntypedIter<'_> ⓘ
pub fn operations(&self) -> UntypedIter<'_> ⓘ
Return an untyped iterator over the operators of the page’s content stream.
Sourcepub fn typed_operations(&self) -> TypedIter<'_> ⓘ
pub fn typed_operations(&self) -> TypedIter<'_> ⓘ
Return a typed iterator over the operators of the page’s content stream.
Examples found in repository?
7fn main() {
8 // First load the data that constitutes the PDF file.
9 let data = std::fs::read(
10 PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../hayro-tests/pdfs/text_with_rise.pdf"),
11 )
12 .unwrap();
13
14 // Then create a new PDF file from it.
15 //
16 // Here we are just unwrapping in case reading the file failed, but you
17 // might instead want to apply proper error handling.
18 let pdf = Pdf::new(Arc::new(data)).unwrap();
19
20 // First access all pages, and then iterate over the operators of each page's
21 // content stream and print them.
22 let pages = pdf.pages();
23 for page in pages.iter() {
24 for op in page.typed_operations() {
25 println!("{op:?}");
26 }
27 }
28}