pub struct PdfPageModel { /* private fields */ }Expand description
一页 PDF 的语义内容。
通过 with_block 逐块构建页面,
可选设置页面尺寸与旋转角度。
Implementations§
Source§impl PdfPageModel
impl PdfPageModel
Sourcepub fn with_block(self, block: PdfBlock) -> Self
pub fn with_block(self, block: PdfBlock) -> Self
追加语义内容块。
Sourcepub const fn with_dimensions(self, width_pt: f64, height_pt: f64) -> Self
pub const fn with_dimensions(self, width_pt: f64, height_pt: f64) -> Self
设置页面尺寸(PDF points)。
Sourcepub const fn with_rotation(self, degrees: u16) -> Self
pub const fn with_rotation(self, degrees: u16) -> Self
设置页面旋转角度(0、90、180、270)。
非标准值会被静默保留,但调用方应仅传入四个标准角度。
Sourcepub const fn number(&self) -> PageNumber
pub const fn number(&self) -> PageNumber
返回一基页码。
Sourcepub fn page_number(&self) -> usize
pub fn page_number(&self) -> usize
返回一基页码数值。
Sourcepub fn blocks_by_type(
&self,
filter: PdfBlockType,
) -> impl Iterator<Item = &PdfBlock>
pub fn blocks_by_type( &self, filter: PdfBlockType, ) -> impl Iterator<Item = &PdfBlock>
按语义分类筛选内容块。
返回迭代器,仅产出匹配指定 PdfBlockType 的块引用。
§Examples
use easypdf_core::{PdfBlock, PdfBlockType, PdfPageModel, SourceLocation};
use easypdf_core::PageIndex;
let loc = SourceLocation::new(PageIndex::new(0), 1.0);
let page = PdfPageModel::new(PageIndex::new(0))
.with_block(PdfBlock::heading(1, "Title", loc))
.with_block(PdfBlock::paragraph("Body", loc));
let headings: Vec<_> = page.blocks_by_type(PdfBlockType::Heading).collect();
assert_eq!(headings.len(), 1);Trait Implementations§
Source§impl Clone for PdfPageModel
impl Clone for PdfPageModel
Source§fn clone(&self) -> PdfPageModel
fn clone(&self) -> PdfPageModel
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PdfPageModel
impl Debug for PdfPageModel
Source§impl PartialEq for PdfPageModel
impl PartialEq for PdfPageModel
impl StructuralPartialEq for PdfPageModel
Auto Trait Implementations§
impl Freeze for PdfPageModel
impl RefUnwindSafe for PdfPageModel
impl Send for PdfPageModel
impl Sync for PdfPageModel
impl Unpin for PdfPageModel
impl UnsafeUnpin for PdfPageModel
impl UnwindSafe for PdfPageModel
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
Converts
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> ⓘ
Converts
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