PDFium Delphi Component Docs

InspectPdfUaLanguageCoverage method

Component: TPdf  ·  Unit: PDFium
Reports effective PDF/UA language coverage for page text and structure accessibility strings

Syntax

function InspectPdfUaLanguageCoverage: TPdfUaLanguageCoverageReport; overload;
function InspectPdfUaLanguageCoverage(const Options: TPdfUaLanguageCoverageOptions): TPdfUaLanguageCoverageReport; overload;

Description

The method scans non-Artifact text page objects plus structure-element Title, AlternateText, ActualText, and Expansion strings

Effective language follows ISO 14289-1 inheritance order: the innermost marked-content /Lang declaration, the nearest structure ancestor with a language, then the catalog language

An invalid nearer declaration remains authoritative and produces uncovered evidence instead of falling through to a valid outer declaration

Each TPdfUaLanguageSpan records PageNumber, PageObjectIndex, MCID, StructureElementIndex, a ContentKind of pulckPageText, pulckTitle, pulckAlternateText, pulckActualText, or pulckExpansion, the full CharacterCount, a bounded Text excerpt flagged by TextTruncated, and the effective language with its DeclarationValid state

Language resolution is reported through TPdfUaLanguageResolution with the Language tag, a Source of pulsNone, pulsCatalog, pulsStructure, or pulsMarkedContent, the originating StructureElementIndex, DeclarationValid, and the IsCovered helper

The default options store only uncovered spans, cap evidence at 1000 spans, and cap each excerpt at 256 characters while aggregate counts continue across the whole document

Completed is False when required PDFium APIs are unavailable, a page cannot be loaded, or bounded structure traversal cannot finish; already collected evidence remains available

Options and result

MemberPurpose
IncludeCoveredSpansStores covered evidence as well as uncovered evidence
MaxReportedSpansCaps stored evidence without stopping aggregate counting
MaxTextCharactersPerSpanCaps each stored excerpt while preserving CharacterCount
CoveredSpanCount, UncoveredSpanCountAggregate language-coverage counts alongside NaturalLanguageSpanCount
DocumentLanguage, PageCount, PagesScannedCatalog language tag and page-scan progress of the TPdfUaLanguageCoverageReport
ReportLimitReachedIndicates that additional matching spans were counted but not stored
IsCoveredReturns True only for a completed scan with no uncovered spans

Example

var Report: TPdfUaLanguageCoverageReport;
Report := Pdf1.InspectPdfUaLanguageCoverage;
if Report.Completed and (Report.UncoveredSpanCount > 0) then
  ShowMessage(IntToStr(Report.UncoveredSpanCount) + ' language declarations required');

See Also

ValidatePdfUa, Structure traversal, PDF standards helpers