/ViewerPreferences 字典中的 /NumCopies 項目property PrintCopies: Integer; // read only
PDF 可能帶有一個建議性的列印偏好,用來建議列印對話框應預先填入的份數。該偏好位於型錄的 /ViewerPreferences /NumCopies 之下(PDF 32000-1 § 12.2 Table 150)。PrintCopies 會公開解碼後的值:存在時為正整數;若 PDF 未設定該欄位則為 0(此時實作應將其視為 1)
這只是作者內嵌在檔案中的提示;它對 PDFium 的算繪沒有影響,也不會改變文件的點陣化方式。若要實際列印多份,您的應用程式仍須把份數傳遞給自己的列印層(Windows GDI StartDoc、第三方列印元件等)
配套屬性 PrintScaling、PrintPaperHandling 與 PrintPageRanges 會公開同一字典中的其他檢視器偏好列印提示,讓您可以一次把它們全部套用到列印對話框。如需原始字串形式,可使用 ViewerPreference['NumCopies']
PrintCopies = 0 表示「文件中不存在此偏好」Printer 或其他任何列印 API 結合使用
// Pre-fill the spin edit with the document's suggested copies count.
var N: Integer;
begin
N := Pdf1.PrintCopies;
if N < 1 then N := 1;
spinCopies.MinValue := 1;
spinCopies.MaxValue := 999;
spinCopies.Value := N;
Memo1.Lines.Add(Format('PDF suggests %d copies', [N]));
end;