DeletePages
Page manipulation
Description
Removes one or more pages from the document. The document will always have at least one page.
Syntax
Delphi
Function TPDFlib.DeletePages(StartPage, PageCount: Integer): Integer;
ActiveX
Function PDFlib::DeletePages(StartPage As Long, PageCount As Long) As Long
DLL
int DLDeletePages(int InstanceID, int StartPage, int PageCount);
Parameters
| StartPage | The page number of the first page to delete |
|---|---|
| PageCount | The total number of pages to delete. The value will be automatically adjusted if necessary so that the document is left with at least one page. |
Return values
| 0 | The PageCount parameter was 0 or there was only a single page in the document. |
|---|---|
| Non-zero | The number of pages remaining in the original document. |
Remarks
Deletion preserves content streams and resources shared by retained pages, including resources reached through nested Form XObjects
Deletion detaches page references without erasing original object bodies; enable SetGarbageCollect before saving to omit unreachable objects, or use GarbageCollectObjects explicitly
Besides removing the pages, the method cleans up what still points at them. An outline item whose destination or GoTo action targets a deleted page keeps its title but loses that destination. Article thread beads on the deleted pages are unlinked from their threads, and a thread with no beads left is removed. Form widgets on the deleted pages are taken out of their fields, and a field whose widgets were all on those pages is removed from the form, whilst a field with widgets on other pages keeps them. Named destinations aimed at a deleted page are removed from both the catalog /Dests dictionary and the /Names /Dests name tree. Page labels are renumbered so every remaining page keeps the label it showed before
In a tagged document, marked-content identifiers, marked-content references (/MCR) and object references (/OBJR) on the deleted pages are pruned from the structure tree, and a structure element left with no content is removed from its parent. An element that still has content on the remaining pages is kept, and drops its /Pg entry when that entry named a deleted page. The /ParentTree is left unchanged