function ImportPagesByIndex(
Source : TPdf;
const PageIndices: array of Integer;
InsertAt : Integer = 0): Boolean;
ImportPagesByIndex 會從 Source 複製一組明確指定的頁面到
本文件。與解析以 1 為基底範圍字串("1-3,7,10-12")的 ImportPages 不同,
ImportPagesByIndex 直接接受以 0 為基底的 Pascal 開放陣列作為索引 —
當頁面清單來自程式邏輯(勾選的縮圖清單、篩選後的查詢等)時最為理想
InsertAt 是第一個匯入頁面在目的端以 0 為基底的索引:
傳入 0 表示插入在現有第 1 頁之前,傳入 PageCount 則附加到
最後。超出範圍的 InsertAt 值會被 PDFium 限制在邊界內
傳入空的 PageIndices 陣列可匯入 Source 的全部頁面
(等同於在 C ABI 層級傳入 nil)。這是單次呼叫即可匯入全部頁面的簡寫
成功時傳回 True。若任一索引在 Source 中超出範圍,
或任一文件未處於 Active 狀態,則傳回
False。當 Source 為 nil 時會引發 EPdfError
MovePages 就地重新排序PageIndices 中的索引會以 Source 當時的狀態評估;呼叫後對 Source 的重新排序或刪除不會回溯改變已匯入的內容ImportNPagesToOne
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;