Declaration
function ImportPagesIntoPDF(const DestFilename: String; const SourceFilename: String; const Pages: array of Integer; InsertIndex: Integer = -1): Boolean; overload;
function ImportPagesIntoPDF(const DestFilename: String; const SourceFilename: String; const PgIndex, PgCount: Integer; InsertIndex: Integer = -1): Boolean; overload;
function ImportPagesIntoPDF(const DestFilename: String; const SourceFilename: String; const ImportRange: string = ''; InsertIndex: Integer = -1): Boolean; overload;
Description
Import pages into a new or existing PDF from another PDF file.
The pages to import are specified by
ImportRange or the
Pages array. If a null value is specified, ALL pages are imported.
ImportRange is a string, e.g. "1,3,5-7". IT IS ONE-BASED.
Pages is an array of page indexes, e.g. [0, 2, 4, 5, 6]. IT IS ZERO-BASED.
PgIndex, PgCount specifies a range of page indexes, e.g. 0 to 6. IT IS ZERO-BASED.
The following will have the same effect:
ImportPagesIntoPDF( 'C:\Document.pdf', 'C:\SrcDocument.pdf', '1,3,5-7' );
ImportPagesIntoPDF( 'C:\Document.pdf', 'C:\SrcDocument.pdf', [0, 2, 4, 5, 6] );
InsertIndex specifies the insertion position, e.g. specifying 1 will make the imported document the second page (becomes index 1). If -1 is specified, the pages are added to the end of the document.
If
DestFilename does not exist it will be created and filled with the specified pages.
Result will be true if the import succeeds.
Note: These methods require the
PDFium PlugIn
// Copy all pages from a PDF File
ImportPagesIntoPDF( 'C:\Document.pdf', 'C:\SrcDocument.pdf' );
// Import the first page from a PDF File and make it the first page of this document
ImportPagesIntoPDF( 'C:\Document.pdf', 'C:\SrcDocument.pdf', [0], 0 );
// Which is the same as
ImportPagesIntoPDF( 'C:\Document.pdf', 'C:\SrcDocument.pdf', '1', 0 );
See Also
◼DeletePagesFromPDF
◼IEPDFPageCount