[]
        
(Showing Draft Content)

PdfPageCollection

Class: PdfPageCollection

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

Extends

Accessors

count

Get Signature

get count(): number;

Gets the number of items in the collection.

Returns

number

Overrides

PdfCollection.count

doc

Get Signature

get doc(): PdfDocument;

Gets the owner PdfDocument.

Returns

PdfDocument


id

Get Signature

get id(): number;

Gets the reference to the object.

Returns

number

Inherited from

PdfCollection.id

last

Get Signature

get last(): TItem;

Gets last item in the collection.

Returns

TItem

Inherited from

PdfCollection.last

om

Get Signature

get om(): ObjectManager;

Gets the owner ObjectManager instance.

Returns

ObjectManager

Inherited from

PdfCollection.om

Methods

add()

add(item): void;

Adds an item to the end of the collection.

Parameters

item

PdfPage

The item to add.

Returns

void

Inherited from

PdfCollection.add

addNew()

Call Signature

addNew(): PdfPage;

Adds a new PdfPage to the end of the collection.

Returns

PdfPage

A PdfPage object added to the collection.

Call Signature

addNew(width, height): PdfPage;

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.

Example
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();

clear()

clear(): void;

Clears the collection.

Returns

void

Overrides

PdfCollection.clear

clone()

clone(
   sourceIndex, 
   destinationIndex, 
   cloneAnnotations?, 
   cloneFields?): 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

Indicates whether to clone page annotations.

cloneFields?

boolean

Indicates whether to clone fields existing on the source page.

Returns

void


contains()

contains(page): boolean;

Determines whether the item is in the collection.

Parameters

page

PdfPage

Returns

boolean

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

Overrides

PdfCollection.contains

free()

free(): void;

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

Returns

void

Inherited from

PdfCollection.free

getAt()

getAt(index): PdfPage;

Gets the item with the specified index.

Parameters

index

number

The index of the item.

Returns

PdfPage

Overrides

PdfCollection.getAt

insert()

insert(index, page): void;

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

Overrides

PdfCollection.insert

insertNew()

Call Signature

insertNew(index): PdfPage;

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.

Call Signature

insertNew(
   index, 
   width, 
   height): PdfPage;

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.


move()

move(sourceIndex, destinationIndex): void;

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


rebind()

rebind(omTo): void;

Rebinds the object from the current ObjectManager to the specified one.

Parameters

omTo

ObjectManager

The new ObjectManager for the object.

Returns

void

Inherited from

PdfCollection.rebind

remove()

remove(page): boolean;

Removes the specified item from the collection.

Parameters

page

PdfPage

Returns

boolean

true if the item was actually removed, false otherwise.

Overrides

PdfCollection.remove

removeAt()

removeAt(index): void;

Removes the item at specified index.

Parameters

index

number

The index of the item to remove.

Returns

void

Overrides

PdfCollection.removeAt

setAt()

setAt(index, page): void;

Sets the item at the specified index.

Parameters

index

number

The index of the item, starting from 0.

page

PdfPage

Returns

void

Overrides

PdfCollection.setAt

swap()

swap(pageIndex1, pageIndex2): 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