Docs de PDFiumPas

ImportPagesByIndex Método

Esta entrada API conserva identificadores, firmas, bloques de código y términos PDF en su forma original.
Componente: TPdf  ·  Unidad: PDFium
Importa un subconjunto concreto de páginas de otro TPdf por índice basado en cero, con control sobre el punto de inserción en el documento actual

Sintaxis

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

Descripción

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.

Notas

Ejemplo

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;

Véase también

ImportPages, ImportNPagesToOne, MovePages