PDFium Delphi Component Docs

FPdfPreflightReport unit

Enterprise edition: this unit ships in Lib\Enterprise and is linked by FPdfEnterprise and the PDFiumPasEnt / PDFiumLazEnt packages; see the edition matrix

Unit: FPdfPreflightReport
Builds a reusable, queryable report object from the built-in PDF standards validators and exports text, HTML, Markdown, JSON, CSV, SARIF 2.1.0, JUnit XML, NDJSON, or native XML

Syntax

function BuildPdfPreflightReport(Pdf: TPdf): TPdfPreflightReport; overload;
function BuildPdfPreflightReport(Pdf: TPdf; Standards: TPdfPreflightStandards): TPdfPreflightReport; overload;
function PdfPreflightIssueSeverity(Standard: TPdfPreflightStandard; const Code, Category: string): TPdfPreflightSeverity;
function PdfPreflightSeverityName(Severity: TPdfPreflightSeverity): string;
function PdfPreflightStandardName(Standard: TPdfPreflightStandard): string;
function PdfPreflightStatusName(Status: TPdfPreflightStatus): string;
function CreateDefaultPdfValidationRuleRegistry: TPdfValidationRuleRegistry;
function ValidatePdfFilesParallel(const FileNames: array of string; Registry: TPdfValidationRuleRegistry; const Options: TPdfBatchValidationOptions): TPdfBatchValidationReport;

Public Types

TypeDescription
TPdfPreflightStandardStandard selector with ppsPdfA, ppsPdfUa, ppsPdfE, ppsPdfX, ppsPdfR, and ppsPdfVT
TPdfPreflightStandardsSet type used by BuildPdfPreflightReport; AllPdfPreflightStandards selects every supported standard
TPdfPreflightStatusPer-standard status: pfsPass, pfsActionRequired, or pfsReview
TPdfPreflightSeverityIssue severity with psevInfo, psevWarning, or psevError; TPdfPreflightSeverities is the matching filter set
TPdfPreflightIssueIssue row with StandardName, issue code, category, severity, description, and Recommendation, plus MatchesText case-insensitive search and a StableKey identity
TPdfPreflightIssueCategoryCountAggregated issue-category row returned by IssueCategoryCounts
TPdfPreflightSeverityCountAggregated severity row returned by SeverityCounts with Severity, SeverityName, and Count
TPdfPreflightIssueCodeCountAggregated standard and issue-code row returned by IssueCodeCounts with StandardName, Code, and Count
TPdfPreflightStandardResultOne standard result with StandardName, ConformanceName, IsCompliant, StatusName, Priority, NextAction, the Issues array, ErrorCount and WarningCount severity counters, HighestSeverity, IssueCount, and HasIssueCode issue-code lookup
TPdfPreflightReportComplete report with the SourceFile name, GeneratedAt timestamp, ScopeNote, the Results array of standard results, ActionRequiredStandardCount, CompliantStandardCount, NonCompliantStandardCount, PassedStandardCount, ReviewStandardCount, StandardCount, HighestSeverity, and TotalIssueCount summary counters, FilterByStandards, FilterByCategory, FilterBySeverities, SearchIssues, FlattenIssues, HasIssueCode, FindStandard, Fingerprint, IssueCategoryCounts, IssueCodeCounts, and SeverityCounts query helpers, and ToCsv, ToHtml, ToMarkdown, ToJson, ToNdjson, ToSarif, ToJUnitXml, ToText, ToXml export helpers with matching SaveXxxToFile procedures
TPdfValidationRuleDeclarative profile clause with its Id and Profile, Clause, severity, DependencyIds, FixHint repair guidance, IssueCode, and an issue, standard, or custom Predicate chosen by PredicateKind
TPdfValidationBudgetLimits selected rules (MaxRules), reported failures (MaxIssues), visited objects (MaxObjects), recursion (MaxRecursionDepth), evidence bytes (MaxEvidenceBytes), reserved memory (MaxMemoryBytes), and elapsed time (TimeoutMilliseconds)
TPdfValidationOptionsSelects Profiles and Severities, supplies the Budget, enables FastFail, and supports cooperative cancellation through CancellationToken
TPdfValidationExecutionContextBounded execution context handed to custom predicates; Create stores the options and starts the run clock, Checkpoint, ConsumeEvidence, ConsumeObjects, EnterRecursion, LeaveRecursion, ReserveMemory, and ReleaseMemory enforce the budget, and BudgetExceeded, BudgetReason, EvidenceBytes, ObjectsVisited, RecursionDepth, ReservedMemory, PeakReservedMemory, and StartTick expose live counters
TPdfValidationRuleRegistryThread-safe rule registry; Create and Destroy manage the critical section, RegisterRule and Clear mutate the registered set, Count and Snapshot read it under lock, and Execute validates a report with per-clause evidence and timing
TPdfBatchValidationOptionsControls the WorkerCount, the Standards selected for each per-file preflight build, nested ValidationOptions, document-level FailFast, and cancellation through CancellationToken
TPdfBatchValidationReportInput-ordered per-document results with aggregate issue distributions, ElapsedMilliseconds, terminal status, and the WorkerCount, PassedDocumentCount, FailedDocumentCount, CancelledDocumentCount, and ErrorDocumentCount totals
TPdfARepairPlanDependency-ordered remediation Steps classified by category, safety, rewrite need, signature impact, and blocking state, with DocumentHasSignatures, AllowSignatureInvalidation, BlockedStepCount, AutomaticStepCount, and ManualStepCount rollups, IsExecutable, and ToJson JSON output
TPdfARepairCategoryClassifies repair work as parcSecurity, parcFonts, parcColour, parcAttachments, parcStructure, parcMetadata, or parcOther work
TPdfARepairSafetyparsAutomatic, parsReviewRequired, or parsManual
TPdfARepairStepOne ordered repair action with its Order, category, IssueCode, action, Evidence, dependency, and Safety, plus RequiresFullRewrite, InvalidatesSignatures, and Blocked
TPdfXProductionPreflightOptionsControls the MinimumImageDpi threshold, TreatTransparencyAsErrorBeforePdfX4, and IncludeInformationalColourants reporting
TPdfXProductionPreflightReportPDF/X Validation result plus the per-page Pages facts, HasOutputIntent, HasEmbeddedFonts, HasTransparency, HasOverprint, SeparationCount, DeviceNCount, MinimumEffectiveDpi, the Issues array, ErrorCount, IsProductionReady, and ToJson JSON output
TPdfXProductionIssueKindClassifies pxpikOutputIntent, pxpikPageBox, pxpikFont, pxpikColourant, pxpikTransparency, pxpikOverprint, pxpikSeparation, and pxpikImageResolution issues
TPdfXProductionIssueOne focused production finding with its Kind, severity, PageNumber, ObjectIndex, and Evidence
TPdfXProductionPagePer-page facts for PageNumber, HasMediaBox, HasTrimBox, HasBleedBox, HasArtBox, TextObjectCount, PathObjectCount, ImageCount, HasTransparency, and MinimumEffectiveDpi
TPdfValidationPredicateKindSelects pvpkIssueAbsent, pvpkStandardPass, or pvpkCustom rule evaluation
TPdfValidationRuleStatuspvrrsPass, pvrrsFail, pvrrsSkipped, or pvrrsError
TPdfValidationRunStatusReports pvrsComplete, pvrsFastFailed, pvrsBudgetExceeded, pvrsCancelled, or pvrsError
TPdfValidationRuleResultPer-rule result with RuleId, Profile, Clause, status, Evidence, FixHint repair guidance, and ElapsedMilliseconds
TPdfValidationRunOne bounded registry execution with the Results array, PassedRuleCount, FailedRuleCount, SkippedRuleCount, and ErrorRuleCount counters, ObjectsVisited, EvidenceBytes, PeakReservedMemory, ElapsedMilliseconds, IncompleteReason, and compliance helpers
TPdfPreflightIssues, TPdfPreflightStandardResultsDynamic arrays holding issue rows and per-standard results
TPdfPreflightIssueCategoryCounts, TPdfPreflightSeverityCounts, TPdfPreflightIssueCodeCountsDynamic arrays returned by the category, severity, and stable issue-code aggregators
TPdfARepairStepsDependency-ordered PDF/A repair steps stored by TPdfARepairPlan
TPdfXProductionPages, TPdfXProductionIssuesPer-page production facts and focused PDF/X production issues
TPdfValidationProfiles, TPdfValidationRules, TPdfValidationRuleResultsSelected profile names, registered declarative rules, and per-rule execution results
TPdfValidationRulePredicateCustom rule callback that evaluates a report through a bounded execution context and returns diagnostic evidence
TPdfBatchValidationItemStatusPer-document pbvisPending, pbvisPass, pbvisFail, pbvisCancelled, or pbvisError state
TPdfBatchValidationStatusWhole-batch pbvsComplete, pbvsPartial, pbvsCancelled, or pbvsFailed state
TPdfBatchValidationItemOne input file named by FileName with its Preflight report, the rule Validation result, status, ErrorMessage text, and ElapsedMilliseconds
TPdfBatchValidationItemsInput-ordered per-document results returned by parallel validation

Description

BuildPdfPreflightReport calls ValidatePdfA, ValidatePdfUa, ValidatePdfE, ValidatePdfX, ValidatePdfR, and ValidatePdfVT for an active TPdf document and returns a TPdfPreflightReport

The report contains one row per selected standard, detected conformance, status, priority, next action, issue code, category, Info / Warning / Error severity, description, and recommendation. Status, severity, category, and issue-code counters expose reusable summary data

PdfPreflightStandardName, PdfPreflightStatusName, and PdfPreflightSeverityName map the standard, status, and severity enums to the stable display names used by the exports, such as PDF/A, Action required, and Warning

PdfPreflightIssueSeverity derives the severity of a marker-level issue from its standard, code, and category: review and advisory categories report psevInfo, Metadata issues whose code does not mention missing, invalid, or mismatch report psevWarning, and every other issue reports psevError, with PDF/UA language metadata always reported as an error

FindStandard, HasIssueCode, FlattenIssues, SearchIssues, FilterByStandards, FilterBySeverities, and FilterByCategory provide in-memory query views. Filtered reports preserve original conformance and status values while returning independent issue arrays

Fingerprint returns a lowercase SHA-256 identity for the ordered standard and issue result set. Source paths and generation timestamps are intentionally excluded so equivalent validation results share one fingerprint

Each To* export has a matching Save*ToFile method. Files are written directly as UTF-8; CSV retains a BOM for Excel detection and neutralizes formula-leading cells

The file-writing procedures are TPdfPreflightReport.SaveTextToFile, TPdfPreflightReport.SaveHtmlToFile, TPdfPreflightReport.SaveMarkdownToFile, TPdfPreflightReport.SaveJsonToFile, TPdfPreflightReport.SaveCsvToFile, TPdfPreflightReport.SaveSarifToFile, TPdfPreflightReport.SaveJUnitXmlToFile, TPdfPreflightReport.SaveNdjsonToFile, and TPdfPreflightReport.SaveXmlToFile; each creates or replaces the named file with the matching export rendering

TPdfValidationRuleRegistry executes declarative profile clauses outside the monolithic standard validators. Rules can depend on earlier clauses, select a built-in issue or profile predicate, or provide a custom predicate that records bounded evidence

CreateDefaultPdfValidationRuleRegistry returns a registry preloaded with one StandardPass profile rule per supported standard, each failing with error severity and standard-specific fix guidance when its standard did not pass, so rule evaluation works without hand-registering clauses

TPdfValidationRule.IssueAbsent builds a rule from its rule id, profile, clause, description, issue code, fix hint, and severity, tagging it with the Conformance category, the pvpkIssueAbsent predicate kind, and the ppsPdfA standard with no dependencies and no custom predicate; evaluation passes exactly when that issue code is absent from the report

TPdfValidationExecutionContext provides cooperative checkpoints and explicit counters for objects, recursion, UTF-8 evidence, and reserved memory. A run reports fast-fail, cancellation, or budget exhaustion as an incomplete status rather than a complete compliance result

TPdfValidationOptions.Default applies no profile filter, selects every severity, nests TPdfValidationBudget.Default, disables FastFail, and attaches no cancellation token

TPdfValidationBudget.Default allows 10,000 rules, 1,000 issues, 10,000,000 visited objects, 256 recursion levels, 16 MiB of evidence, and 256 MiB of reserved memory; object, recursion, and memory ceilings are clamped down to the global parser resource budget, and the timeout adopts the parser deadline

TPdfValidationRun.IsComplete is true only for pvrsComplete, so fast-failed, budget-exceeded, cancelled, and errored runs read as incomplete

ValidatePdfFilesParallel gives each worker a private TPdf document, preserves input order, aggregates issue-code counts, and records pass, fail, cancellation, or load errors independently for every file

The workers share one lock that serialises their PDFium calls, but that lock does not cover other users of PDFium in the process. Do not render in a TPdfView, run TPdfAsyncExecutor tasks or call other PDFium-backed APIs from other threads while ValidatePdfFilesParallel is running

PDFium is not thread-safe across documents, so the workers open and inspect files one at a time under a shared lock and run only the rule evaluation in parallel; a larger WorkerCount therefore speeds up rule-heavy registries rather than document loading

TPdfBatchValidationOptions.Default selects every standard, nests TPdfValidationOptions.Default, disables FailFast, attaches no cancellation token, and leaves WorkerCount at zero so the run sizes itself from the processor count, capped at 8 workers and the file count

TPdfBatchValidationReport.IsComplete is true only for pbvsComplete, separating a fully processed batch from partial, cancelled, and failed outcomes

BuildPdfARepairPlan maps PDF/A evidence into security, font, colour, attachment, structure, metadata, and residual steps in dependency order. Signature-invalidating steps are blocked unless the caller supplies explicit authorization

BuildPdfXProductionPreflight combines the PDF/X profile result with native page and image facts, structural colourant and overprint scans, and page-box checks. It never decodes or copies image payloads during resolution analysis

TPdfXProductionPreflightOptions.Default sets MinimumImageDpi to 150, enables TreatTransparencyAsErrorBeforePdfX4, and turns on IncludeInformationalColourants

Output Formats

FormatShape
TextPlain-text source, generated time, scope note, summary, standard rows, action plan, issue categories, and issue details
HTMLStandalone HTML report with status styling, an issue-category table, standard table, and issue table
MarkdownMarkdown headings and tables for standards, issue categories, action plan, and issue details
JSONStructured object with format, sourceKind, summary, issueCategoryCounts, and per-standard issue arrays
CSVSpreadsheet-friendly rows identified by RowType: Summary, Standard, Category, and Issue
SARIF 2.1.0CI and code-scanning results with stable rule IDs, severity levels, remediation messages, properties, and partial fingerprints
JUnit XMLOne test case per selected standard, with Action required results emitted as failures and Review results emitted as skipped cases
NDJSONOne summary, standard, or issue JSON object per line for incremental ingestion without loading one large JSON document
XMLNative preflight XML with report metadata, summary attributes, standard results, severity, descriptions, and recommendations

Remarks

Example

uses FPdfPreflightReport;

var
  Report: TPdfPreflightReport;
begin
  Pdf1.FileName := 'C:\Incoming\job.pdf';
  Pdf1.Active := True;
  Report := BuildPdfPreflightReport(Pdf1, [ppsPdfA, ppsPdfX]);
  Memo1.Lines.Text := Report.ToText;
  Report.SaveHtmlToFile('C:\Incoming\job.preflight.html');
  Report.SaveMarkdownToFile('C:\Incoming\job.preflight.md');
  Report.SaveJsonToFile('C:\Incoming\job.preflight.json');
  Report.SaveCsvToFile('C:\Incoming\job.preflight.csv');
  Report.SaveSarifToFile('C:\Incoming\job.preflight.sarif');
  Report.SaveJUnitXmlToFile('C:\Incoming\job.preflight.junit.xml');
  Report.SaveNdjsonToFile('C:\Incoming\job.preflight.ndjson');
  Report.SaveXmlToFile('C:\Incoming\job.preflight.xml');
end;

See Also

ValidatePdfA, ValidatePdfX