Struct pdfium_render::pdfium::Pdfium
source · [−]pub struct Pdfium { /* private fields */ }Expand description
A high-level idiomatic Rust wrapper around Pdfium, the C++ PDF library used by the Google Chromium project.
Implementations
Initializes the external pdfium library, loading it from the system libraries. Returns a new PdfiumLibraryBindings object that contains bindings to the functions exposed by the library, or an error if the library could not be loaded.
pub fn bind_to_library(
path: impl ToString
) -> Result<Box<dyn PdfiumLibraryBindings>, PdfiumError>
pub fn bind_to_library(
path: impl ToString
) -> Result<Box<dyn PdfiumLibraryBindings>, PdfiumError>
Initializes the external pdfium library, loading it from the given path. Returns a new PdfiumLibraryBindings object that contains bindings to the functions exposed by the library, or an error if the library could not be loaded.
Returns the name of the external Pdfium library on the currently running platform. On Linux and Android, this will be libpdfium.so or similar; on Windows, this will be pdfium.dll or similar; on MacOS, this will be libpdfium.dylib or similar.
Returns the name of the external Pdfium library on the currently running platform, prefixed with the given path string.
Creates a new Pdfium object from the given external pdfium library bindings.
pub fn load_pdf_from_file(
&self,
path: &str,
password: Option<&str>
) -> Result<PdfDocument<'_>, PdfiumError>
pub fn load_pdf_from_file(
&self,
path: &str,
password: Option<&str>
) -> Result<PdfDocument<'_>, PdfiumError>
Attempts to open a PdfDocument from the given file path.
If the document is password protected, the given password will be used to unlock it.
This function is not available when compiling to WASM. Either embed the bytes of
the target PDF document directly into the compiled WASM module using the
include_bytes!() macro, or use Javascript’s fetch() API to retrieve the bytes
of the target document over the network, then load those bytes into Pdfium using
the load_pdf_from_bytes() function.
pub fn load_pdf_from_bytes(
&self,
bytes: &[u8],
password: Option<&str>
) -> Result<PdfDocument<'_>, PdfiumError>
pub fn load_pdf_from_bytes(
&self,
bytes: &[u8],
password: Option<&str>
) -> Result<PdfDocument<'_>, PdfiumError>
Attempts to open a PdfDocument from the given byte buffer.
If the document is password protected, the given password will be used to unlock it.