pub struct PdfDocument {
pub version: String,
pub objects: Vec<PdfObject>,
pub pages: Vec<PdfPage>,
pub info: PdfInfo,
pub image_xobjects: Vec<ImageXObject>,
pub gradients: Vec<PdfGradient>,
pub ext_g_states: Vec<PdfExtGState>,
pub outline: Option<PdfOutline>,
pub font_manager: FontManager,
pub encryption: Option<EncryptionDict>,
pub file_id: Option<Vec<u8>>,
pub compliance: PdfCompliance,
}Expand description
PDF document structure
Fields§
§version: StringPDF version (e.g., “1.4”)
objects: Vec<PdfObject>Objects in the PDF
pages: Vec<PdfPage>Page tree
info: PdfInfoDocument info
image_xobjects: Vec<ImageXObject>Image XObjects (shared resources)
gradients: Vec<PdfGradient>Gradient shading patterns (shared resources)
ext_g_states: Vec<PdfExtGState>Extended Graphics States for transparency
outline: Option<PdfOutline>Document outline (bookmarks)
font_manager: FontManagerFont manager for embedded fonts
encryption: Option<EncryptionDict>Encryption settings (if set, all streams/strings will be encrypted)
file_id: Option<Vec<u8>>File ID for the /ID entry in the trailer (required for encryption)
compliance: PdfCompliancePDF compliance mode (Standard, PDF/A-1b, PDF/UA-1, or both)
Implementations§
Source§impl PdfDocument
impl PdfDocument
Sourcepub fn set_compliance(&mut self, compliance: PdfCompliance) -> Result<()>
pub fn set_compliance(&mut self, compliance: PdfCompliance) -> Result<()>
Set the PDF compliance mode
§Errors
Returns an error if PDF/A compliance is requested together with encryption, since PDF/A-1b (ISO 19005-1) forbids encryption.
Sourcepub fn add_image_xobject(&mut self, xobject: ImageXObject) -> usize
pub fn add_image_xobject(&mut self, xobject: ImageXObject) -> usize
Add an image XObject to the document and return its index
Sourcepub fn add_gradient(&mut self, gradient: Gradient) -> usize
pub fn add_gradient(&mut self, gradient: Gradient) -> usize
Add a gradient shading pattern to the document and return its index
The gradient will be registered as a PDF shading pattern resource. Returns the index that can be used to reference this gradient.
Sourcepub fn add_ext_g_state(
&mut self,
fill_opacity: f64,
stroke_opacity: f64,
) -> usize
pub fn add_ext_g_state( &mut self, fill_opacity: f64, stroke_opacity: f64, ) -> usize
Add an ExtGState for opacity/transparency and return its index
Creates an Extended Graphics State dictionary with the specified opacity values. Returns the index that can be used to reference this graphics state.
§Arguments
fill_opacity- Opacity for fill operations (0.0 = transparent, 1.0 = opaque)stroke_opacity- Opacity for stroke operations (0.0 = transparent, 1.0 = opaque)
Sourcepub fn set_outline(&mut self, outline: PdfOutline)
pub fn set_outline(&mut self, outline: PdfOutline)
Set the document outline (bookmarks)
Sourcepub fn set_encryption(
&mut self,
encryption: EncryptionDict,
file_id: Vec<u8>,
) -> Result<()>
pub fn set_encryption( &mut self, encryption: EncryptionDict, file_id: Vec<u8>, ) -> Result<()>
Set encryption for the document
When encryption is set, to_bytes() will encrypt all content streams
and string objects, and include the /Encrypt dictionary in the trailer.
§Errors
Returns an error if PDF/A compliance mode is active, since PDF/A-1b (ISO 19005-1 §6.1.1) forbids encryption.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PdfDocument
impl RefUnwindSafe for PdfDocument
impl Send for PdfDocument
impl Sync for PdfDocument
impl Unpin for PdfDocument
impl UnsafeUnpin for PdfDocument
impl UnwindSafe for PdfDocument
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().