property Language: WString; // read / write
Language reads and writes the document catalog’s /Lang entry
(PDF 1.7 spec section 14.9.2). The string follows RFC 3066 / BCP 47 language tag
syntax — en, en-US, zh-Hans,
ja-JP, etc. Screen readers and accessibility tools (PDF/UA, JAWS, NVDA)
use this tag to choose the correct pronunciation engine when reading tagged text aloud.
Returns an empty string when Active is False or when the
document does not declare /Lang. Assigning a new value updates the catalog
immediately but the change is only persisted by the next SaveToFile /
SaveToStream call. Span-level language overrides on individual text
structure elements (set through the /Lang entry on a structure element
dictionary) are not exposed by this property.
Language is independent of the encoding used for text content — PDFium always decodes character data to UTF-16, regardless of language. The tag is purely metadata, mainly relevant for tagged / PDF-UA accessible documents and for indexing engines that route extracted text through language-specific tokenisers.
/Lang entry. Setting Language is a one-line fix when validating a
tagged PDF.IsTagged to detect whether the document advertises an
accessibility tree at all.en-US, not EN-us). PDFiumVCL preserves casing
verbatim.
if Pdf1.Language = '' then
begin
Pdf1.Language := 'en-US';
Pdf1.SaveToFile('tagged.pdf');
end
else
Label1.Caption := 'Document language: ' + Pdf1.Language;