DsPdfJS API - v9.1.0
    Preparing search index...

    Class PdfPageCollection

    Represents a collection of pages that make up a PDF document.

    Hierarchy

    • PdfCollection<PdfPage>
      • PdfPageCollection
    Index

    Accessors

    • get count(): number

      Gets the number of items in the collection.

      Returns number

    • get id(): number

      Gets the reference to the object.

      Returns number

    • get last(): TItem | null

      Gets last item in the collection.

      Returns TItem | null

    Methods

    • Adds an item to the end of the collection.

      Parameters

      Returns void

    • Adds a new PdfPage to the end of the collection.

      Returns PdfPage

      A PdfPage object added to the collection.

    • Creates a new PdfPage with the specified size and adds it to the end of the collection.

      Parameters

      • width: number

        The width of the new page, in points.

      • height: number

        The height of the new page, in points.

      Returns PdfPage

      A PdfPage object added to the collection.

      const doc = new PdfDocument();
      const page = doc.pages.addNew(500, 350);
      page.context.drawEllipse(100, 100, 300, 150, {
      fillColor: "MediumAquamarine",
      lineColor: "Teal",
      lineWidth: 10
      });
      const res: Uint8Array = doc.savePdf();
    • Clears the collection.

      Returns void

    • Clones a page at a specified index (sourceIndex) and inserts it at a specified position (destinationIndex).

      Parameters

      • sourceIndex: number

        The index of the page to clone.

      • destinationIndex: number

        The destination index.

      • cloneAnnotations: boolean = true

        Indicates whether to clone page annotations.

      • cloneFields: boolean = true

        Indicates whether to clone fields existing on the source page.

      Returns void

    • Determines whether the item is in the collection.

      Parameters

      Returns boolean

      true if the item is in the collection, false otherwise.

    • Detaches the object from the ObjectManager and deallocates its memory, if possible.

      Returns void

    • Gets the item with the specified index.

      Parameters

      • index: number

        The index of the item.

      Returns PdfPage

    • Inserts an item at a specific position in the collection.

      Parameters

      • index: number

        The position where the item will be inserted.

      • page: PdfPage

      Returns void

    • Inserts a new PdfPage at a specific position in the collection.

      Parameters

      • index: number

        The position where the new page will be inserted.

      Returns PdfPage

      A PdfPage object inserted in the collection.

    • Creates a new PdfPage with the specified size and inserts it at a specific position in the collection.

      Parameters

      • index: number

        The position where the new page will be inserted.

      • width: number

        The width of the new page, in points.

      • height: number

        The height of the new page, in points.

      Returns PdfPage

      A PdfPage object inserted in the collection.

    • Moves a page specified by its 0-based index to another position in the page collection.

      Parameters

      • sourceIndex: number

        The current index of the page to move.

      • destinationIndex: number

        The new index of the page.

      Returns void

    • Removes the specified item from the collection.

      Parameters

      Returns boolean

      true if the item was actually removed, false otherwise.

    • Removes the item at specified index.

      Parameters

      • index: number

        The index of the item to remove.

      Returns void

    • Sets the item at the specified index.

      Parameters

      • index: number

        The index of the item, starting from 0.

      • page: PdfPage

      Returns void

    • Swaps two pages specified by their 0-based indices.

      Parameters

      • pageIndex1: number

        The index of the first page to swap.

      • pageIndex2: number

        The index of the second page to swap.

      Returns void