Struct pdfium_render::attachment::PdfAttachment
source · 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.