|
These methods provide a loaded-document workflow for inserting, extracting, copying, saving, and reordering pages
Delphi syntax:
function HPDFParsePageRange(const PageRange: string; PageCount: Integer): THPDFPageIndexArray;
procedure AppendPagesFromDocument(SourceDoc: THotPDF; const PageRange: string);
procedure InsertPagesFromDocument(SourceDoc: THotPDF; const PageRange: string; InsertAfterPage: Integer);
procedure InsertPagesFromDocument(SourceDoc: THotPDF; const LogicalPageIndices: array of Integer; InsertAfterPage: Integer);
procedure CopyPageByPhysicalIndex(SourceDoc: THotPDF; SourceIndex: Integer; DestIndex: Integer);
procedure ExtractPagesToFile(const OutputFile: TFileName; const PageRange: string);
procedure ExtractPagesToFile(const OutputFile: TFileName; const LogicalPageIndices: array of Integer);
procedure MovePage(PageIndex: Integer; NewPageIndex: Integer);
procedure SaveLoadedDocument(const TargetFile: TFileName);
property OnPageOperationProgress: THPDFPageOperationProgressEvent;
Description
HPDFParsePageRange converts one-based range strings such as 1,3-4,6- into zero-based page indices. Empty input selects every page. Invalid page numbers, descending ranges, and malformed tokens raise an exception
InsertPagesFromDocument copies pages from another loaded THotPDF instance into the current document. Existing zero-based array calls remain supported, and the string overload accepts one-based page ranges. InsertAfterPage is zero-based; pass -1 to insert at the beginning
AppendPagesFromDocument appends the selected source pages to the end of the current document using the same one-based page-range syntax
CopyPageByPhysicalIndex copies one source page by its zero-based physical page index into a zero-based destination position
ExtractPagesToFile writes selected pages from the current document into a new PDF file. Existing zero-based array calls remain supported, and the string overload accepts one-based page ranges
OnPageOperationProgress reports page-level progress for append, insert, extract, and future merge-style page operations
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
SaveLoadedDocument writes the loaded object graph to a new file after page edits, form edits, or copy operations
Code Example
BasePDF.LoadFromFile('base.pdf');
InsertPDF.LoadFromFile('insert.pdf');
BasePDF.InsertPagesFromDocument(InsertPDF, '1-2', 0);
BasePDF.AppendPagesFromDocument(InsertPDF, '2');
BasePDF.MovePage(BasePDF.PagesCount - 1, 1);
BasePDF.ExtractPagesToFile('selected-pages.pdf', '2,4');
BasePDF.SaveLoadedDocument('reordered.pdf');
|