|
These methods provide a loaded-document workflow for inserting, extracting, and reordering pages.
Delphi syntax:
procedure InsertPagesFromDocument(SourceDoc: THotPDF; const LogicalPageIndices: array of Integer; InsertAfterPage: Integer);
procedure ExtractPagesToFile(const OutputFile: TFileName; const LogicalPageIndices: array of Integer);
procedure MovePage(PageIndex: Integer; NewPageIndex: Integer);
Description
InsertPagesFromDocument copies the selected zero-based logical pages from another loaded THotPDF instance into the current document. InsertAfterPage is zero-based; pass -1 to insert at the beginning. An empty page-index array inserts every page from the source document.
ExtractPagesToFile writes the selected zero-based pages from the current document into a new PDF file. An empty page-index array extracts every page.
MovePage reorders the current document by moving one zero-based page to another zero-based position. The method updates the loaded page array and the root page tree so subsequent saves and extraction calls use the new order.
Code Example
BasePDF.LoadFromFile('base.pdf');
InsertPDF.LoadFromFile('insert.pdf');
BasePDF.InsertPagesFromDocument(InsertPDF, [0, 1], 0);
BasePDF.MovePage(BasePDF.PagesCount - 1, 1);
BasePDF.ExtractPagesToFile('selected-pages.pdf', [1, 3]);
BasePDF.SaveLoadedDocument('reordered.pdf');
|