CheckDocumentPolicy
Document properties, Compliance
Description
Evaluates a list of declarative house rules against the document and reports which ones pass.
Syntax
Delphi
Function TPDFlib.CheckDocumentPolicy(Const Rules: WideString): Integer;Parameters
| Rules | One assertion per line in the form Group.Key op Value. Blank lines and lines starting with # are ignored. |
|---|
Return values
| 0 | No document is selected, or the rule text is empty. |
|---|---|
| ID | A string list handle for GetStringListCount and GetStringListItem; release it with ReleaseStringList. |
Remarks
Rule subjects address the feature report produced by GetDocumentFeatureReport: the Group,Key,Value line Fonts,NotEmbedded,0 is addressed as Fonts.NotEmbedded. Supported operators are =, !=, <, <=, >, >= and exists; comparison is numeric when both sides parse as numbers and case-insensitive text otherwise.
Each result line is pass or fail followed by the rule and the actual value, and the last line is summary,N passed,M failed. Unknown feature keys, malformed rules and unsupported operators are reported as failures rather than silently ignored, so a typo in a policy file cannot make a document look compliant.
This turns an ingest gate into configuration: publishers, archives and print shops can enforce fully embedded fonts, forbidden encryption, page limits or required metadata without writing inspection code.
Example
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);See also
GetDocumentFeatureReport, CheckDocumentStructure, CheckFileCompliance