CollateDocuments

Page manipulation, Document assembly

Description

Merges pages from one or more open source documents into the selected document in rotation, taking a fixed number of pages from each source per round.

Syntax

Delphi

Function TPDFlib.CollateDocuments(Const SourceDocumentIDs: Array Of Integer; GroupSize: Integer): Integer;

Parameters

SourceDocumentIDsHandles of the open source documents, as returned by NewDocument or the load functions. The selected document must not appear in the list.
GroupSizeNumber of pages appended from each source per round. Pass 1 for strict alternation (A1, B1, A2, B2, …).

Return values

0Invalid arguments, or the copy failed; the selected document is unchanged.
1The pages were collated onto the end of the selected document.

Remarks

The collated block is appended after the existing pages of the selected document. Each source is imported once through a single object map, so fonts and images shared inside a source are written only once; the interleaved order is then produced by page reordering without copying any objects. Sources with fewer pages simply drop out of later rounds.

Use CollateDocumentsEx to collate page subsets or reversed page order.

Example

Fronts:= PDF.NewDocument;
PDF.LoadFromFile('odd-pages.pdf', '');
Backs:= PDF.NewDocument;
PDF.LoadFromFile('even-pages.pdf', '');
PDF.SelectDocument(Target);
PDF.CollateDocuments([Fronts, Backs], 1);

See also

CollateDocumentsEx, CopyPageRanges, MergeFileList