PdfPageCollection Class
The pages of a document, in the order of the page tree (ISO 32000-2, 7.7.3).
public sealed class PdfPageCollection : IEnumerable<PdfPage>, IReadOnlyCollection<PdfPage>, IReadOnlyList<PdfPage>, IEnumerableRemarks
The page tree of a file is kept: a page is added to the node of the page it is inserted before (or of the last page), and the /Count entries of the nodes above a change are updated. A node that is reached twice, or that is not a dictionary, is skipped. A page that changes of node keeps its attributes: the attributes it inherited (resources, media box, crop box, rotation, 7.7.3.4) are copied to it first.
Properties
| Name | Description |
|---|---|
| Count | Gets the number of pages. |
Count
PdfPageCollection.csIndexers
| Name | Description |
|---|---|
| this[int] | Gets a page. |
this[int]
PdfPageCollection.csMethods
| Name | Description |
|---|---|
| Add(PdfPage) | Adds a copy of a page at the end of the document. The page can be a page of another document. |
| Add(PdfSize) | Adds a page at the end of the document. |
| Duplicate(int) | Inserts a copy of a page of the document after it. |
| GetEnumerator() | Returns an enumerator over the pages. |
| IndexOf(PdfPage) | Gets the index of a page. |
| Insert(int, PdfPage) | Inserts a copy of a page. The page can be a page of this document (a duplicate) or of another document (an import, to merge documents). |
| Insert(int, PdfSize) | Inserts a page. |
| Move(int, int) | Moves a page to another position. Its object does not change: the destinations, links and structure elements that refer to it stay valid. |
| RemoveAt(int) | Removes a page from the page tree. Its objects are not written by a full save anymore: the references of the document to the page are removed too. The outline items and the links that go to the page lose their destination (the items and the links stay), the named destinations of the page and the /OpenAction that goes to it are removed, and so are its marked content and its annotations in the structure tree. |
| System.Collections.IEnumerable.GetEnumerator() |
Add overloads
Add(PdfPage)
PdfPageCollection.csAdds a copy of a page at the end of the document. The page can be a page of another document.
Add(PdfSize)
PdfPageCollection.csDuplicate(int)
PdfPageCollection.csGetEnumerator()
PdfPageCollection.csReturns an enumerator over the pages.
public IEnumerator<PdfPage> GetEnumerator()Returns
IEnumerator<PdfPage> The enumerator.
IndexOf(PdfPage)
PdfPageCollection.csInsert overloads
Insert(int, PdfPage)
PdfPageCollection.csInserts a copy of a page. The page can be a page of this document (a duplicate) or of another document (an import, to merge documents).
Parameters
indexint- The index of the copy, from 0 to
PdfPageCollection.Count. pagePdfPage- The page to copy.
Returns
PdfPage The copy.
Remarks
The copy has the attributes of the page, the ones it inherited included, its content and its annotations, except the form fields (widgets) and the pop-up windows. It is not tagged: its /StructParents and the structure of its annotations are left out, since the structure tree belongs to the document of the page.
A page of this document shares its content streams and its resources with the copy. A page of another document is copied with the objects it uses, renumbered: the objects shared by several imported pages of a document, such as the fonts, are copied once. The document must stay open until the copy is saved. The destinations of the links go to the copies of their pages: a destination to a page that is not imported yet goes to it when it is, and has no page (null) otherwise; a named destination is replaced by the destination it names.
Insert(int, PdfSize)
PdfPageCollection.csInserts a page.
Parameters
indexint- The index of the new page, from 0 to
PdfPageCollection.Count. sizePdfSize- The size of the page (its media box).
Returns
PdfPage The new page. It does not inherit the rotation nor the crop box of the node of the page tree it is added to.
Move(int, int)
PdfPageCollection.csRemoveAt(int)
PdfPageCollection.csRemoves a page from the page tree. Its objects are not written by a full save anymore: the references of the document to the page are removed too. The outline items and the links that go to the page lose their destination (the items and the links stay), the named destinations of the page and the /OpenAction that goes to it are removed, and so are its marked content and its annotations in the structure tree.
Parameters
indexint- The index of the page.