ImageEn, unit iexUserInteractions

TIEPdfViewer.ImportPages

TIEPdfViewer.ImportPages


Declaration

function ImportPages(const Filename: String; const Pages: array of Integer; InsertIndex: Integer = -1; const Password: AnsiString = ''): Boolean; overload;
function ImportPages(const Filename: String; const ImportRange: string = ''; InsertIndex: Integer = -1; const Password: AnsiString = ''): Boolean; overload;
function ImportPages(const Filename: String; const PgIndex, PgCount: Integer; InsertIndex: Integer = -1; const Password: UTF8String = ''): Boolean; overload;
function ImportPages(Stream: TStream; const Pages: array of Integer; InsertIndex: Integer = -1; const Password: AnsiString = ''): Boolean; overload;
function ImportPages(Stream: TStream; const ImportRange: string = ''; InsertIndex: Integer = -1; const Password: AnsiString = ''): Boolean; overload;
function ImportPages(Stream: TStream; const PgIndex, PgCount: Integer; InsertIndex: Integer = -1; const Password: UTF8String = ''): Boolean; overload;
function ImportPages(Document: TPdfDocument; const Pages: array of Integer; InsertIndex: Integer = -1): Boolean; overload;
function ImportPages(Document: TPdfDocument; const ImportRange: string = ''; InsertIndex: Integer = -1): Boolean; overload;
function ImportPages(Document: TPdfDocument; const PgIndex, PgCount: Integer; InsertIndex: Integer = -1): Boolean; overload;


Description

Import pages from another PDF file or PdfViewer.
Specify a filename (and optionally password) or a TIEPdfViewer.Document.

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:

ImageEnView1.PdfViewer.ImportPages( 'C:\Document.pdf', '1,3,5-7' );
ImageEnView1.PdfViewer.ImportPages( 'C:\Document.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.

Result will be true if the import succeeds.

Note:
- DocModified will be true after importing
- ImportPages will automatically create a new empty document if one is not loaded


Demo

Demo  Demos\Other\PdfViewer\PdfViewer.dpr


Examples

// Copy all pages from a PDF File (to the end of this document)
ImageEnView1.PdfViewer.ImportPages( 'C:\Document.pdf' );

// Import the first page from a PDF File and make it the first page of this document
ImageEnView1.PdfViewer.ImportPages( 'C:\Document.pdf', [0], 0 );

// Which is the same as:
ImageEnView1.PdfViewer.ImportPages( 'C:\Document.pdf', '1', 0 );

// Copy all pages from another TImageEnView
ImageEnView1.PdfViewer.ImportPages( ImageEnView1.PdfViewer.Document );

// Import all pages from a stream
fs := TFileStream.Create('d:\test.pdf', fmOpenRead);
try
  fs.Seek(0, soEnd);
  fs.Position := 0;
  ImageEnView1.PdfViewer.ImportPages( fs, '', ImageEnView1.PdfViewer.PageCount );
finally
  fs.Free;
end;


See Also

- ImportPagesIntoPDF
- DeletePages
- MovePages
- ExportPages