pub struct PdfPages<'a> { /* private fields */ }
Expand description

The collection of PdfPage objects inside a PdfDocument.

Implementations

Returns the PdfiumLibraryBindings used by the containing PdfDocument.

Returns the number of pages in this PdfPages collection.

Returns true if this PdfPages collection is empty.

Returns a Range from 0..(number of pages) for this PdfPages collection.

Returns an inclusive Range from 0..=(number of pages - 1) for this PdfPages collection.

Returns a single PdfPage from this PdfPages collection.

Creates a new, empty PdfPage with the given PdfPagePaperSize and inserts it at the start of this PdfPages collection, shuffling down all other pages.

Creates a new, empty PdfPage with the given PdfPagePaperSize and adds it to the end of this PdfPages collection.

Creates a new, empty PdfPage with the given PdfPagePaperSize and inserts it into this PdfPages collection at the given page index.

Deletes the page at the given index from this PdfPages collection.

Copies a single page with the given source page index from the given source PdfDocument, inserting it at the given destination page index in this PdfPages collection.

Copies one or more pages, specified using a user-friendly page range string, from the given source PdfDocument, inserting the pages sequentially starting at the given destination page index in this PdfPages collection.

The page range string should be in a comma-separated list of indexes and ranges, for example "1,3,5-7". Pages are indexed starting at one, not zero.

Copies one or more pages with the given range of indices from the given source PdfDocument, inserting the pages sequentially starting at the given destination page index in this PdfPages collection.

Copies all pages in the given source PdfDocument, appending them sequentially to the end of this PdfPages collection.

For finer control over which pages are imported, and where they should be inserted, use one of the PdfPages::copy_page_from_document(), PdfPages::copy_pages_from_document(), or PdfPages::copy_page_range_from_document() functions.

Creates a new PdfDocument by copying the pages in this PdfPages collection into tiled grids, the size of each tile shrinking or expanding as necessary to fit the given PdfPagePaperSize.

For example, to output all pages in a PdfPages collection into a new A3 landscape document with six source pages tiled on each destination page arranged into a 2 row x 3 column grid, you would call:

PdfPages::tile_into_new_document(2, 3, PdfPagePaperSize::a3().to_landscape())

Returns the PdfPageMode setting embedded in the containing PdfDocument.

Applies the given watermarking closure to each PdfPage in this PdfPages collection.

The closure receives four arguments:

  • An empty PdfPageGroupObject for you to populate with the page objects that make up your watermark.
  • The zero-based index of the PdfPage currently being processed.
  • The width of the PdfPage currently being processed, in PdfPoints.
  • The height of the PdfPage currently being processed, in PdfPoints.

If the current page should not be watermarked, simply leave the group empty.

The closure can return a Result<(), PdfiumError>; this makes it easy to use the ? unwrapping operator within the closure.

For example, the following snippet adds a page number to the very top of every page in a document except for the first page.

    document.pages().watermark(|group, index, width, height| {
        if index == 0 {
            // Don't watermark the first page.

            Ok(())
        } else {
            let mut page_number = PdfPageTextObject::new(
                &document,
                format!("Page {}", index + 1),
                &PdfFont::helvetica(&document),
                PdfPoints::new(14.0),
            )?;

            page_number.translate(
                (width - page_number.width()?) / 2.0, // Horizontally center the page number...
                height - page_number.height()?, // ... and vertically position it at the page top.
            )?;

            group.push(&mut page_number.into())
        }
    })?;

Returns an iterator over all the pages in this PdfPages collection.

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
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.