[]
Represents a collection of pages that make up a PDF document.
PdfCollection<PdfPage>get count(): number;
Gets the number of items in the collection.
number
PdfCollection.count
get doc(): PdfDocument;
Gets the owner PdfDocument.
get id(): number;
Gets the reference to the object.
number
PdfCollection.id
get last(): TItem;
Gets last item in the collection.
TItem
PdfCollection.last
get om(): ObjectManager;
Gets the owner ObjectManager instance.
PdfCollection.om
add(item): void;
Adds an item to the end of the collection.
The item to add.
void
PdfCollection.add
addNew(): PdfPage;
Adds a new PdfPage to the end of the collection.
A PdfPage object added to the collection.
addNew(width, height): PdfPage;
Creates a new PdfPage with the specified size and adds it to the end of the collection.
number
The width of the new page, in points.
number
The height of the new page, in points.
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();
clear(): void;
Clears the collection.
void
PdfCollection.clear
clone(
sourceIndex,
destinationIndex,
cloneAnnotations?,
cloneFields?): void;
Clones a page at a specified index (sourceIndex) and inserts it at a specified position (destinationIndex).
number
The index of the page to clone.
number
The destination index.
boolean
Indicates whether to clone page annotations.
boolean
Indicates whether to clone fields existing on the source page.
void
contains(page): boolean;
Determines whether the item is in the collection.
boolean
true if the item is in the collection, false otherwise.
PdfCollection.contains
free(): void;
Detaches the object from the ObjectManager and deallocates its memory, if possible.
void
PdfCollection.free
getAt(index): PdfPage;
Gets the item with the specified index.
number
The index of the item.
PdfCollection.getAt
insert(index, page): void;
Inserts an item at a specific position in the collection.
number
The position where the item will be inserted.
void
PdfCollection.insert
insertNew(index): PdfPage;
Inserts a new PdfPage at a specific position in the collection.
number
The position where the new page will be inserted.
A PdfPage object inserted in the collection.
insertNew(
index,
width,
height): PdfPage;
Creates a new PdfPage with the specified size and inserts it at a specific position in the collection.
number
The position where the new page will be inserted.
number
The width of the new page, in points.
number
The height of the new page, in points.
A PdfPage object inserted in the collection.
move(sourceIndex, destinationIndex): void;
Moves a page specified by its 0-based index to another position in the page collection.
number
The current index of the page to move.
number
The new index of the page.
void
rebind(omTo): void;
Rebinds the object from the current ObjectManager to the specified one.
The new ObjectManager for the object.
void
PdfCollection.rebind
remove(page): boolean;
Removes the specified item from the collection.
boolean
true if the item was actually removed, false otherwise.
PdfCollection.remove
removeAt(index): void;
Removes the item at specified index.
number
The index of the item to remove.
void
PdfCollection.removeAt
setAt(index, page): void;
Sets the item at the specified index.
number
The index of the item, starting from 0.
void
PdfCollection.setAt
swap(pageIndex1, pageIndex2): void;
Swaps two pages specified by their 0-based indices.
number
The index of the first page to swap.
number
The index of the second page to swap.
void