Pages methods reference

Count()

Returns the number of items (integer) in the Pages collection, in other words the number of pages in the PDF.

Syntax

Count()

Return value

Integer. The number of pages in the PDF.

Delete()

Deletes a page from the PDF.

Syntax

Delete(index)

index

Integer. 0-based index of the page to delete.

ExtractTo(destFilename, srcIndex, srcCount, optimize)

Extracts pages from the PDF and creates a new file with these pages. All relevant resources are copied with the pages. If the target file already exists, it is overwritten.

Syntax

ExtractTo(destFilename, srcIndex, srcCount, optimize)

destFilename

String. Name string of the PDF to create with the specified pages.

srcIndex

Integer. 0-based index of the first page to copy.

srcCount

Integer. Number of contiguous pages starting from srcIndex to extract.

optimize

Boolean. If true, optimize (linearize and garbage-collect) the output file.

Insert(index, mediaSize)

Inserts a new blank page in the PDF file. See also: Count().

Syntax

Insert(index, mediaSize)

index

Integer. 0-based index at which to insert the page. The page is inserted before the page at index "index ". To insert a page at the end, use Pages.Count().

mediaSize

PdfRect structure containing the rectangular dimensions of the new page, in points. Cannot be undefined (null).

InsertFrom(srcFilename, srcIndex, srcCount, destIndex)

Inserts pages from another PDF file into this one. All relevant resources are copied with the pages. See also: Count().

Syntax

InsertFrom(srcFilename, srcIndex, srcCount, destIndex)

srcFilename

String. Name of the PDF from which pages are retrieved.

srcIndex

Integer. 0-based index of the first page to copy.

srcCount

Integer. Number of contiguous pages starting from srcIndex to insert. If srcCount is -1, all pages from srcIndex up to the end are inserted.

destIndex

Integer. 0-based index of the position where to insert the pages. They will be inserted before the page at index destIndex. To insert the pages at the end, use Pages.Count().

InsertFrom2(srcPages, srcIndex, srcCount, destIndex)

Inserts pages from another Pages object into this one. All relevant resources are copied with the pages. See also: Count().

Syntax

InsertFrom2(srcPages, srcIndex, srcCount, destIndex)

srcPages

Pages collection from which the pages are retrieved.

srcIndex

Integer. 0-based index of the first page to copy.

srcCount

Integer. Number of contiguous pages starting from srcIndex to insert. If srcCount is -1, all pages from srcIndex up to the end are inserted.

destIndex

Integer. 0-based index of the position where to insert the pages. They will be inserted before the page at index destIndex. To insert the pages at the end, use Pages.Count().

Item(index)

Returns a Page object from the PDF. Note that since Item() is the collection's default method, it can be omitted altogether (e.g. Pages(0) is the same as Pages.Item(0)).

Syntax

Item(index)

index

Integer. 0-based index of the page to acquire.

Return value

A Page object for the specified page. (See Page object.)

Move(index, count, offset)

Moves a range of pages within the same PDF.

Syntax

Move( index, count, offset)

index

Integer. 0-based index of the first page of the range.

count

Integer. Number of contiguous pages to move.

offset

Integer. Number of hops to move the pages. If negative, the pages are moved towards the beginning of the file. If positive, towards the end.