PDFium Component Docs

ImportPagesByIndex メソッド

この API エントリでは識別子、シグネチャ、コードブロック、PDF 用語を元の表記のまま保持します。
コンポーネント: TPdf  ·  ユニット: PDFium
別の TPdf から 0 始まりの index で指定したページの一部を取り込み、現在の文書内での挿入位置を制御します

構文

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

説明

ImportPagesByIndexSource から明示的に選んだページ群をこの文書へコピーします。1 始まりの range string ("1-3,7,10-12") を解釈する ImportPages とは違い、ImportPagesByIndex は index をそのまま 0 始まりの Pascal open array として受け取ります。checked list of thumbnails や filtered query など、ページ一覧がプログラムの論理から来る場合に向いています

InsertAt は最初に取り込むページの 0 始まりの destination index です。0 を渡すと既存の page 1 の前に挿入し、PageCount を渡すと末尾に追加します。範囲外の InsertAt は PDFium が丸めます

空の PageIndices 配列を渡すと、Source の全ページを取り込みます (C ABI レベルでは nil を渡すのと同じです)。これは 1 回の呼び出しで全部取り込むための省略形です

成功すると True を返します。Source の index が範囲外、またはどちらかの文書が Active でない場合は False を返します。Sourcenil のときは EPdfError を送出します

備考

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;

関連項目

ImportPages, ImportNPagesToOne, MovePages