function ImportPagesByIndex(
Source : TPdf;
const PageIndices: array of Integer;
InsertAt : Integer = 0): Boolean;
ImportPagesByIndex 会把 Source 中显式指定的一组页面复制到此文档。与解析一基范围字符串("1-3,7,10-12")的 ImportPages 不同,ImportPagesByIndex 直接把索引作为零基 Pascal 开放数组接收,这在页面列表来自程序逻辑时非常合适,例如勾选的缩略图列表或过滤后的查询结果
InsertAt 是第一个被导入页面的零基目标索引:传入 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;