Skip to content

Layout: one general diagnostics channel and an opt-in strict mode (the additive half of #496 and the channel of #304) #607

Closed

Description

@Tim81

The maintainer confirmed this split on 2026-11-18 (decision D7): this issue carries the additive general diagnostics
channel and #304's opt-in strict switch, and #496 stays in v3.0 for unifying TextEncodingWarnings and
BandTruncations.

Where this sits in the tracker

Two open issues already describe parts of this work. This issue states which part it delivers.

Problem

Document has two one-off report lists and no place for the many other things the library knows and cannot refuse
in a minor release. (origin/main 1c61fa6, src/VellumPdf.Layout/Document.cs.)

42:     private readonly List<TextEncodingWarning> _textEncodingWarnings = [];
44:     private readonly List<BandTruncationWarning> _bandTruncations = [];
57:     public IReadOnlyList<TextEncodingWarning> TextEncodingWarnings => _textEncodingWarnings;
70:     public IReadOnlyList<BandTruncationWarning> BandTruncations => _bandTruncations;
...
1014:     private void CollectDiagnostics(DocumentRenderer renderer)
1016:         _textEncodingWarnings.Clear();
1017:         _textEncodingWarnings.AddRange(renderer.TextEncodingWarnings);

The contract for refusals is already decided in the tracker. #474: "The fix must not be a hard refusal at Save", and
the right shape is "the notify-and-continue channel this library already has". #484 (v3.0) is where refusals of
input that renders today move.

Why it matters

Several v2.4 items change from silent to reported, and none may turn a document that renders today into an exception
by default: #592 (glyph 0), #593 (font fallback), #598 (unknown band token), #583 (missing alt text), the
PDF/UA claim checks of #474 (title, language, embedded fonts), the heading checks of #514 (negative or skipped level)
and #611 (control characters in cells). Seven separate lists would add seven public members that behave
differently, which is the pattern #496 warns about.

Scope

Acceptance

  • A document that triggers two different codes lists two items with their codes, clauses and locations (exact strings
    asserted).
  • 100,000 occurrences of one missing character produce one item with a count (assert the count of items and the
    count field; no wall-clock assertion).
  • Strict mode throws on an error item and writes nothing to the stream (assert the stream is empty).
  • Default mode with the same document saves with the bytes it saves today.
  • A failed save leaves a previous list untouched. A Document is single-use (Document.cs:1025-1033: a second save
    after a success throws), so the test builds two documents and checks that each reports only its own items.
  • A document with no problems has an empty list and a strict save succeeds.
  • TextEncodingWarnings and BandTruncations return what they return on origin/main 1c61fa6 for the same inputs
    (test pins both).
  • The test fails on origin/main 1c61fa6 (no such member), proven by mutation.

Relates to

Activity

  1. added
    enhancement
    area/layout
    type/feature
    on Nov 18, 2026
  2. Tim81 commented on Nov 18, 2026

    @Tim81
    OwnerAuthor

    Requirement added by the maintainer's decision of 2026-11-18. 2.x follows "valid file = keep" (#484's contract): any input for which 2.x writes a valid PDF keeps saving, even when content is lost or misplaced. Examples from PR #571's review, measured on main 1c61fa6 (2.3.3 plus dependency updates): a table with an infinite top margin is not drawn, and a JBIG2 image with an unknown-length segment embeds blank.

    For this channel that means:

    • Every input that 2.x keeps rendering under that rule gets its own diagnostic code.
    • Strict mode refuses each of those codes.
    • 3.0 makes strict the only behaviour, so the switch goes away and each code becomes a refusal.

    The umbrella for the 3.0 side is #614. #607 stays the 2.x half: the channel, the codes and the opt-in switch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/layoutenhancementtype/feature

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions