Skip to content

Layout: a Preformatted block cannot declare its language, so text in another language than the document's is read in the document's #759

Backlog

Description

@Tim81

Why

ISO 14289-1, 7.2: natural language "shall be declared" as ISO 32000-1, 14.9.2 describes, and "changes in natural language shall be declared". ISO 19005-2, 6.7.4 (level A, a should): text in another language than the catalog's /Lang is marked with Lang on a structure element or marked content. ISO 32000-1, 14.9.2.3: Lang on a structure element applies to its content and descendants.

Paragraph, Heading, ListItem and a table Cell each have a Language member that is written as /Lang on the structure element they produce, and a NoteBlock takes it from the paragraphs it holds. Preformatted has none, so the one P it writes for each drawn piece never has a /Lang, and a block of text that is not in the document's language is read in the document's language by a screen reader.

Measured on origin/main b2791ba, saved under PDF/A-2a and PDF/UA-1, in the audit fixture languages (ConformanceAuditG3Tests.Iso14289_1_7_2_ALanguageSetOnAnElementIsLangOnItsStructureElementAndOnNoOther): a paragraph nl-NL, a heading fr, a note-block paragraph de, a list item es and two cells it and pt-BR each have /Lang on their element, and the P of new Preformatted("code", ...) has none. typeof(Preformatted).GetProperty("Language") is null; the skipped test Iso14289_1_7_2_APreformattedBlockCanDeclareItsLanguage asserts the member exists.

veraPDF 1.30.4 passes the file (it checks only the syntax of a Lang that is present: 6.7.4-1 and 7.2-29), so no oracle shows it.

Sweep: git grep -n "string? Language" HEAD -- src on b2791ba finds the member on Heading, ListItem, Paragraph, Cell, Layout.Document, PdfDocument and PdfStructElem. Of the Layout elements that write a structure element (Paragraph, Heading, ListElement, NoteBlock, TableElement, Preformatted, LayoutImage, PieChart), Preformatted is the one text element with no member; LayoutImage and PieChart carry alternative text and no language for it, which is #583's territory. A language inside a paragraph, heading or list item is #584.

Proposal

Preformatted.Language, init-only and null by default, written as /Lang on every P the block produces, with the same documentation as Paragraph.Language. A null value writes the bytes of today. Document in the "Do not pass" paragraph what a value that is not a language tag does under a PDF/A-2a or PDF/UA-1 claim, as #749 decides for the other members.

Acceptance

  • The skipped test Iso14289_1_7_2_APreformattedBlockCanDeclareItsLanguage runs and passes.
  • A tagged document with Language = "de" on a block that splits over two pages has /Lang (de) on both of its P elements, and the same block with no language saves to the bytes of today.
  • veraPDF 2a and UA-1 accept the file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions