CheckDocumentPolicy

文件屬性與遵循性

描述

對文件評估一組宣告式內部規則,回報哪些通過

語法

Delphi

Function TPDFlib.CheckDocumentPolicy(Const Rules: WideString): Integer;

參數

Rules每行一條斷言,格式為 Group.Key op Value。空白行與 # 開頭的行會被忽略。

傳回值

0未選取文件,或規則文字為空。
ID字串清單控制代碼,供 GetStringListCount 與 GetStringListItem 使用;用 ReleaseStringList 釋放。

備註

規則主題指向 GetDocumentFeatureReport 產生的特徵報告:Group,Key,Value 行 Fonts,NotEmbedded,0 的主題寫成 Fonts.NotEmbedded。支援的運算子為 =、!=、<、<=、>、>= 與 exists;兩側都能解析成數字時用數值比較,否則用不分大小寫的文字比較。

每行結果是 pass 或 fail,後接規則與實際值;最後一行是 summary,N passed,M failed。未知的特徵鍵、格式錯誤的規則與不受支援的運算子都會回報為失敗,不會默默忽略——政策檔裡的手滑字不可能讓文件假裝合規。

這把攝入關卡變成配置:出版商、檔案館與印刷廠不必寫檢查程式碼,就能強制完整內嵌字型、禁止加密、限制頁數或要求必要的中繼資料。

範例

Rules:=
  'Fonts.NotEmbedded = 0'#13#10+
  'Security.Encrypted = no'#13#10+
  'Document.Pages <= 500'#13#10+
  'Document.Title exists';
ListID:= PDF.CheckDocumentPolicy(Rules);
Last:= PDF.GetStringListItem(ListID, PDF.GetStringListCount(ListID));
if Pos('0 failed', Last)= 0 then
  ShowMessage('document rejected by policy');
PDF.ReleaseStringList(ListID);

另見

GetDocumentFeatureReport, CheckDocumentStructure, CheckFileCompliance