pub struct PdfAttachment<'a> { /* private fields */ }Expand description
A single attached data file embedded in a PdfDocument.
Implementations§
Source§impl<'a> PdfAttachment<'a>
impl<'a> PdfAttachment<'a>
Sourcepub fn bindings(&self) -> &'a dyn PdfiumLibraryBindings
pub fn bindings(&self) -> &'a dyn PdfiumLibraryBindings
Returns the PdfiumLibraryBindings used by this PdfAttachment.
Sourcepub fn name(&self) -> String
pub fn name(&self) -> String
Returns the name of this PdfAttachment.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the size of this PdfAttachment in bytes.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if there is no byte data associated with this PdfAttachment.
Sourcepub fn save_to_bytes(&self) -> Result<Vec<u8>, PdfiumError>
pub fn save_to_bytes(&self) -> Result<Vec<u8>, PdfiumError>
Writes this PdfAttachment to a new byte buffer, returning the byte buffer.
Sourcepub fn save_to_writer<W: Write>(
&self,
writer: &mut W,
) -> Result<(), PdfiumError>
pub fn save_to_writer<W: Write>( &self, writer: &mut W, ) -> Result<(), PdfiumError>
Writes this PdfAttachment to the given writer.
Sourcepub fn save_to_file(
&self,
path: &(impl AsRef<Path> + ?Sized),
) -> Result<(), PdfiumError>
pub fn save_to_file( &self, path: &(impl AsRef<Path> + ?Sized), ) -> Result<(), PdfiumError>
Writes this PdfAttachment to the file at the given path.
This function is not available when compiling to WASM. You have several options for saving attachment data in WASM:
- Use either the PdfAttachment::save_to_writer() or the PdfAttachment::save_to_bytes() functions, both of which are available when compiling to WASM.
- Use the PdfAttachment::save_to_blob() function to save attachment data directly into a new
Javascript
Blobobject. This function is only available when compiling to WASM.
Sourcepub fn save_to_blob(&self) -> Result<Blob, PdfiumError>
pub fn save_to_blob(&self) -> Result<Blob, PdfiumError>
Writes this PdfAttachment to a new Blob, returning the Blob.
This function is only available when compiling to WASM.
Auto Trait Implementations§
impl<'a> Freeze for PdfAttachment<'a>
impl<'a> !RefUnwindSafe for PdfAttachment<'a>
impl<'a> !Send for PdfAttachment<'a>
impl<'a> !Sync for PdfAttachment<'a>
impl<'a> Unpin for PdfAttachment<'a>
impl<'a> !UnwindSafe for PdfAttachment<'a>
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
Mutably borrows from an owned value. Read more
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