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.

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.

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.

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. You have several options for loading your PDF document data in WASM:

  • Use the Pdfium::load_pdf_from_fetch() function to download document data from a URL using the browser’s built-in fetch() API. This function is only available when compiling to WASM.
  • Use the Pdfium::load_pdf_from_blob() function to load document data from a Javascript File or Blob object (such as a File object returned from an HTML <input type="file"> element). This function is only available when compiling to WASM.
  • Use another method to retrieve the bytes of the target document over the network, then load those bytes into Pdfium using the Pdfium::load_pdf_from_bytes() function.
  • Embed the bytes of the target document directly into the compiled WASM module using the include_bytes!() macro.

Attempts to open a PdfDocument from the given reader.

Pdfium will only load the portions of the document it actually needs into memory. This is more efficient than loading the entire document into memory, especially when working with large documents, and allows for working with documents larger than the amount of available memory.

Because Pdfium must know the total content length in advance prior to loading any portion of it, the given reader must implement the Seek trait as well as the Read trait.

If the document is password protected, the given password will be used to unlock it.

This function is not available when compiling to WASM. You have several options for loading your PDF document data in WASM:

  • Use the Pdfium::load_pdf_from_fetch() function to download document data from a URL using the browser’s built-in fetch() API. This function is only available when compiling to WASM.
  • Use the Pdfium::load_pdf_from_blob() function to load document data from a Javascript File or Blob object (such as a File object returned from an HTML <input type="file"> element). This function is only available when compiling to WASM.
  • Use another method to retrieve the bytes of the target document over the network, then load those bytes into Pdfium using the Pdfium::load_pdf_from_bytes() function.
  • Embed the bytes of the target document directly into the compiled WASM module using the include_bytes!() macro.

Creates a new, empty PdfDocument in memory.

Trait Implementations

Binds to an external Pdfium library, loading it from the system libraries, by calling Pdfium::bind_to_system_library(). This function will panic if no suitable system library can be loaded.

Closes the external pdfium library, releasing held memory.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.