Docs de PDFiumVCL

ImportPagesByIndex method

Esta entrada API conserva identificadores, firmas, bloques de código y términos PDF en su forma original.
Component: TPdf  ·  Unit: PDFium
Imports a specific subset of pages from another TPdf by zero-based index, with control over the insertion point in the current document.

Syntax

function ImportPagesByIndex(
  Source : TPdf;
  const PageIndices: array of Integer;
  InsertAt : Integer = 0): Boolean;

Description

ImportPagesByIndex copies an explicit set of pages from Source into THIS document. Unlike ImportPages, which parses a one-based range string ("1-3,7,10-12"), ImportPagesByIndex takes the indices directly as a zero-based Pascal open array — ideal when the page list comes from program logic (a checked list of thumbnails, a filtered query, etc.).

InsertAt is the zero-based destination index for the FIRST imported page: pass 0 to insert before the existing page 1, pass PageCount to append. Out-of-range InsertAt values are clamped by PDFium.

Pass an empty PageIndices array to import every page from Source (equivalent to passing nil at the C ABI level). This is the one-call-imports-everything shorthand.

Returns True on success. Returns False if any index is out of range in Source or if either document is not Active. Raises EPdfError when Source is nil.

Remarks

Example

var
  Source: TPdf;
begin
  Source := TPdf.Create(nil);
  try
    Source.FileName := 'C:\Report.pdf';
    Source.Active := True;
    // Import pages 1, 3, 5 (zero-based: 0, 2, 4) and append
    Pdf1.ImportPagesByIndex(Source, [0, 2, 4], Pdf1.PageCount);
    // Or import every source page at the start of Pdf1
    // Pdf1.ImportPagesByIndex(Source, [], 0);
  finally
    Source.Free;
  end;
end;

See Also

ImportPages, ImportNPagesToOne, MovePages