AppendPages(PdfDocument, Range) Method

Definition

Namespace Broadside
Assembly Broadside.dll

Appends the pages of source that pages selects to this document, with the outline items, named destinations, form fields and page labels that belong to them.

public void AppendPages(PdfDocument source, Range pages)

Parameters

source
PdfDocument

Another document; it is only read.

pages
Range

The 0-based page indices to copy, such as 2..5 for the third to fifth pages.

Remarks

Pages (§7.7.3) are copied in one PdfObjectCopier session, so what they share is copied once, and added after this document's last page; the page tree is rebuilt balanced, as Insert(Int32, CosReference) rebuilds it.

Outline (§12.3.3): the source's items are added after this document's top-level items, keeping their levels, titles, colours, styles, open states and destinations or actions. When every page is copied every item is; otherwise an item is kept when it shows a copied page or one of its descendants is kept, and a kept item whose own destination is a page not copied loses that destination (it stays as a heading for its descendants). An item's structure element (SE) names the element's copy when the element is copied, and is left out otherwise.

Named destinations (§12.3.2.4): those of the source's Dests name tree and catalog Dests dictionary that show a copied page (all of them when every page is copied) are added to this document's. A name this document already has is renamed by appending _1, _2, … (the first that is free), and every reference to it among the copies (outline items, link annotations, go-to actions and their Next actions) is renamed with it. A destination whose page is given as a page number (a producer error the reader accepts) is given the copied page.

Form fields (§12.7.3, §12.7.4): the source's fields with a widget on a copied page (all of them when every page is copied) are added to this document's interactive form, which is created when absent, with their values; a field's widgets on pages not copied are left out. A top-level field whose name a field of this document has is renamed by appending _1, _2, …, so both keep their values, and the field names in the copies' reset-form, submit-form and hide actions and signature field locks are renamed with it (names inside JavaScript are not). The form's DA and Q are given to the copied top-level fields that do not set their own when they differ from this document's, its DR entries this document lacks are added, NeedAppearances and SigFlags are combined, and its calculation order (CO) is appended. An XFA form is not copied.

Page labels (§12.4.2): when either document has page labels, the copied pages keep the labels they had in the source (a source without labels numbers them in decimal, as a reader would) and this document's pages keep theirs.

Optional content (§8.11.4): the source's optional content groups the copies use (all of them when every page is copied) are listed in this document's OCProperties, which is created when absent, after its own groups, each with its default state; the source's Order, RBGroups, Locked and AS are appended to the default configuration's and its alternate configurations to Configs, each keeping only those groups. This document's own entries are unchanged.

Structure (§14.7): the structure elements with a content item on a copied page (all of them when every page is copied), and their ancestors, are added after this document's top-level elements, which gives this document a structure tree when it has none. An element whose content is partly on pages not copied keeps only its content on copied pages. The copied pages, forms and annotations get new parent-tree keys (§14.7.5.4), so their content finds the copied elements; content that is no element's in the copy loses its key. Namespaces are matched by name, and role map, namespace role map and class map entries this document lacks are added. A structure type this document maps differently, an attribute class it defines differently and an element ID it already has are renamed in the copies by appending _1, _2, … (a table cell's Headers follow the IDs), each recorded as an Information diagnostic (StructureRoleConflict, StructureClassConflict, StructureIdConflict).

Copied objects may raise this document's version on save. A mutation of this document: no read of it may run concurrently; the source may be read by others.