pub struct PdfPage {
pub width: Length,
pub height: Length,
pub content: Vec<u8>,
pub link_annotations: Vec<LinkAnnotation>,
}Expand description
PDF page
Fields§
§width: LengthPage width
height: LengthPage height
content: Vec<u8>Page content stream
link_annotations: Vec<LinkAnnotation>Link annotations on this page
Implementations§
Source§impl PdfPage
impl PdfPage
Sourcepub fn add_link_annotation(
&mut self,
x: Length,
y: Length,
width: Length,
height: Length,
destination: LinkDestination,
)
pub fn add_link_annotation( &mut self, x: Length, y: Length, width: Length, height: Length, destination: LinkDestination, )
Add a link annotation to the page
§Arguments
x- X position (PDF coordinates: bottom-left origin)y- Y position (PDF coordinates: bottom-left origin)width- Width of the clickable areaheight- Height of the clickable areadestination- Link destination (external URL or internal ID)
Sourcepub fn add_text(&mut self, text: &str, x: Length, y: Length, font_size: Length)
pub fn add_text(&mut self, text: &str, x: Length, y: Length, font_size: Length)
Add text to the page using the default Helvetica font (F1)
Sourcepub fn add_text_with_spacing(
&mut self,
text: &str,
x: Length,
y: Length,
font_size: Length,
letter_spacing: Option<Length>,
word_spacing: Option<Length>,
)
pub fn add_text_with_spacing( &mut self, text: &str, x: Length, y: Length, font_size: Length, letter_spacing: Option<Length>, word_spacing: Option<Length>, )
Add text to the page using the default Helvetica font (F1) with optional letter/word spacing
§Arguments
letter_spacing- Optional character spacing in points (Tc operator)word_spacing- Optional word spacing in points (Tw operator)
Sourcepub fn add_text_with_font(
&mut self,
text: &str,
x: Length,
y: Length,
font_size: Length,
font_index: usize,
)
pub fn add_text_with_font( &mut self, text: &str, x: Length, y: Length, font_size: Length, font_index: usize, )
Add text to the page using a custom embedded font
§Arguments
text- The text to displayx- X positiony- Y positionfont_size- Font sizefont_index- Index of the embedded font (fromembed_font)
Note: Character usage tracking must be done separately via FontManager::record_text
Sourcepub fn add_text_with_font_and_spacing(
&mut self,
text: &str,
x: Length,
y: Length,
font_size: Length,
font_index: usize,
letter_spacing: Option<Length>,
word_spacing: Option<Length>,
)
pub fn add_text_with_font_and_spacing( &mut self, text: &str, x: Length, y: Length, font_size: Length, font_index: usize, letter_spacing: Option<Length>, word_spacing: Option<Length>, )
Add text to the page using a custom embedded font with optional letter/word spacing
§Arguments
text- The text to displayx- X positiony- Y positionfont_size- Font sizefont_index- Index of the embedded font (fromembed_font)letter_spacing- Optional character spacing in points (Tc operator)word_spacing- Optional word spacing in points (Tw operator)
Sourcepub fn add_text_with_font_tracked(
&mut self,
text: &str,
x: Length,
y: Length,
font_size: Length,
font_index: usize,
font_manager: &mut FontManager,
)
pub fn add_text_with_font_tracked( &mut self, text: &str, x: Length, y: Length, font_size: Length, font_index: usize, font_manager: &mut FontManager, )
Add text to the page using a custom embedded font and track character usage
This is a convenience method that both adds the text and records character usage for subsetting.
§Arguments
text- The text to displayx- X positiony- Y positionfont_size- Font sizefont_index- Index of the embedded font (fromembed_font)font_manager- FontManager to record character usage
Sourcepub fn add_background(
&mut self,
x: Length,
y: Length,
width: Length,
height: Length,
color: Color,
)
pub fn add_background( &mut self, x: Length, y: Length, width: Length, height: Length, color: Color, )
Add background color to an area
Sourcepub fn add_background_with_radius(
&mut self,
x: Length,
y: Length,
width: Length,
height: Length,
color: Color,
border_radius: Option<[Length; 4]>,
)
pub fn add_background_with_radius( &mut self, x: Length, y: Length, width: Length, height: Length, color: Color, border_radius: Option<[Length; 4]>, )
Add background color to an area with optional rounded corners
Sourcepub fn add_background_with_opacity(
&mut self,
x: Length,
y: Length,
width: Length,
height: Length,
color: Color,
border_radius: Option<[Length; 4]>,
gs_index: usize,
)
pub fn add_background_with_opacity( &mut self, x: Length, y: Length, width: Length, height: Length, color: Color, border_radius: Option<[Length; 4]>, gs_index: usize, )
Add background color with opacity to an area with optional rounded corners
§Arguments
x, y- Bottom-left corner of the area (PDF coordinates)width, height- Dimensions of the areacolor- Fill colorborder_radius- Optional corner radiigs_index- Index of the ExtGState resource for opacity
Sourcepub fn add_gradient_background(
&mut self,
x: Length,
y: Length,
width: Length,
height: Length,
gradient_index: usize,
)
pub fn add_gradient_background( &mut self, x: Length, y: Length, width: Length, height: Length, gradient_index: usize, )
Add gradient background to an area
§Arguments
x, y- Bottom-left corner of the area (PDF coordinates)width, height- Dimensions of the areagradient_index- Index of the gradient in the document’s gradient list
Sourcepub fn add_gradient_background_with_radius(
&mut self,
x: Length,
y: Length,
width: Length,
height: Length,
gradient_index: usize,
border_radius: Option<[Length; 4]>,
)
pub fn add_gradient_background_with_radius( &mut self, x: Length, y: Length, width: Length, height: Length, gradient_index: usize, border_radius: Option<[Length; 4]>, )
Add gradient background to an area with optional rounded corners
§Arguments
x, y- Bottom-left corner of the area (PDF coordinates)width, height- Dimensions of the areagradient_index- Index of the gradient in the document’s gradient listborder_radius- Optional corner radii [top-left, top-right, bottom-right, bottom-left]
Sourcepub fn add_borders(
&mut self,
x: Length,
y: Length,
width: Length,
height: Length,
border_widths: [Length; 4],
border_colors: [Color; 4],
border_styles: [BorderStyle; 4],
)
pub fn add_borders( &mut self, x: Length, y: Length, width: Length, height: Length, border_widths: [Length; 4], border_colors: [Color; 4], border_styles: [BorderStyle; 4], )
Add borders to an area
Sourcepub fn add_borders_with_radius(
&mut self,
x: Length,
y: Length,
width: Length,
height: Length,
border_widths: [Length; 4],
border_colors: [Color; 4],
border_styles: [BorderStyle; 4],
border_radius: Option<[Length; 4]>,
)
pub fn add_borders_with_radius( &mut self, x: Length, y: Length, width: Length, height: Length, border_widths: [Length; 4], border_colors: [Color; 4], border_styles: [BorderStyle; 4], border_radius: Option<[Length; 4]>, )
Add borders to an area with optional rounded corners
Sourcepub fn add_borders_with_opacity(
&mut self,
x: Length,
y: Length,
width: Length,
height: Length,
border_widths: [Length; 4],
border_colors: [Color; 4],
border_styles: [BorderStyle; 4],
border_radius: Option<[Length; 4]>,
gs_index: usize,
)
pub fn add_borders_with_opacity( &mut self, x: Length, y: Length, width: Length, height: Length, border_widths: [Length; 4], border_colors: [Color; 4], border_styles: [BorderStyle; 4], border_radius: Option<[Length; 4]>, gs_index: usize, )
Add borders with opacity to an area with optional rounded corners
Sourcepub fn add_image(
&mut self,
image_index: usize,
x: Length,
y: Length,
width: Length,
height: Length,
)
pub fn add_image( &mut self, image_index: usize, x: Length, y: Length, width: Length, height: Length, )
Add an image to the page
§Arguments
image_index- The index of the image XObject in the document’s image_xobjects listx- X position in PDF coordinates (bottom-left origin)y- Y position in PDF coordinates (bottom-left origin)width- Display widthheight- Display height
Sourcepub fn add_rule(
&mut self,
x: Length,
y: Length,
width: Length,
thickness: Length,
color: Color,
style: &str,
)
pub fn add_rule( &mut self, x: Length, y: Length, width: Length, thickness: Length, color: Color, style: &str, )
Add a horizontal rule (line) to the page
§Arguments
x- Left edge x-coordinatey- Bottom edge y-coordinate (PDF coordinate system)width- Rule widththickness- Line thicknesscolor- Line colorstyle- Line style (solid, dashed, dotted)
Sourcepub fn save_clip_state(
&mut self,
x: Length,
y: Length,
width: Length,
height: Length,
) -> Result<()>
pub fn save_clip_state( &mut self, x: Length, y: Length, width: Length, height: Length, ) -> Result<()>
Save graphics state and set clipping path
This method saves the current graphics state and establishes a rectangular clipping path. Content drawn after this call will be clipped to the specified rectangle until restore_clip_state() is called.
PDF operators used:
- q: Save graphics state
- re: Rectangle path
- W: Set clipping path (intersect with current path)
- n: End path without stroking or filling
§Arguments
x, y- Bottom-left corner of clipping rectangle (PDF coordinates)width, height- Dimensions of clipping rectangle
§PDF Reference
See PDF specification section 8.5 for clipping path details.
Sourcepub fn restore_clip_state(&mut self) -> Result<()>
pub fn restore_clip_state(&mut self) -> Result<()>
Restore graphics state after clipping
This restores the graphics state that was saved by save_clip_state(), removing the clipping path.
PDF operator used:
- Q: Restore graphics state
Auto Trait Implementations§
impl Freeze for PdfPage
impl RefUnwindSafe for PdfPage
impl Send for PdfPage
impl Sync for PdfPage
impl Unpin for PdfPage
impl UnsafeUnpin for PdfPage
impl UnwindSafe for PdfPage
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