CopyPageRangesEx
Extraction, Page manipulation
Description
Use this function to copy one or more pages from one open document to the selected document. Options can preserve the requested page order and enable semantic resource reuse across source documents. Smart resource mode hashes recursively resolved resource graphs before allocation, so equivalent fonts, images, colour spaces, patterns, shadings, and graphics states can share existing target objects even when source object numbers or dictionary order differ. Hash matches receive a structural comparison, whilst cyclic and identity-sensitive page or optional-content objects remain separate
See Page selection syntax for strides, exclusions, open bounds and end-relative selectors
Syntax
Delphi
Function TPDFlib.CopyPageRangesEx(DocumentID: Integer; Const RangeList: WideString; Options: Integer): Integer;
ActiveX
Function PDFlib::CopyPageRangesEx(DocumentID As Long, RangeList As String, Options As Long) As Long
DLL
int DLCopyPageRangesEx(int InstanceID, int DocumentID, const wchar_t* RangeList, int Options);
int DLCopyPageRangesExA(int InstanceID, int DocumentID, const char* RangeList, int Options);
Parameters
| DocumentID | The ID of the document to copy the pages from |
|---|---|
| RangeList | The pages to extract, for example "10,15,18-20,25-35". Invalid characters in the string will be ignored |
| Options | Options is a bit mask. PDF_COPY_PAGE_KEEP_ORDER (1) preserves the requested order and duplicates. PDF_COPY_PAGE_SMART_RESOURCES (2) reuses semantically equivalent resource dictionaries and streams already present in the target. At most one duplicate field name flag may be added: PDF_COPY_PAGE_FAIL_DUPLICATE_FIELDS (4) makes the call fail when a field on the copied pages has the same name as a field already in the target, PDF_COPY_PAGE_SYNC_DUPLICATE_FIELDS (8) gives such a copied field the value and default value of the existing one, and PDF_COPY_PAGE_RENAME_DUPLICATE_FIELDS (16) renames it with a numeric suffix such as Name_2. Combine flags with bitwise OR; 0 sorts the range, ignores duplicates and copies fields under their own names |
Return values
| 0 | The specified DocumentID was not valid or was the same as the selected document, or the RangeList was invalid, or Options contained an unsupported bit |
|---|---|
| 1 | The pages were successfully copied from the specified document to the selected document |
Remarks
Optional content groups (layers) the copied pages use are registered in the target document with their default state, so a layer that was off in the source stays off. A link, widget or bead that points at a page that was not copied is given a null target rather than a reference to an unrelated object. Named destinations that point at a copied page come along, retargeted at the copy; a name the target already uses gets a numeric suffix such as Chap_2, and links on the copied pages follow the new name. The copied pages keep their page labels, continuing the source numbering, whilst the pages already in the target keep theirs. When the source is tagged, the structure elements with content on the copied pages are copied under the target's structure tree, which is created if needed, and the parent tree is rebuilt for the copies; elements whose content was not copied are left out. When PDF_COPY_PAGE_SMART_RESOURCES (2) is set, identical streams and non-structural resource dictionaries inside the copied structure subtree are also deduplicated against the target document