Repository navigation
Open
Description
Follow-up to #510 and PR #542. The review rounds on #542 kept finding reachable behaviour that was already in the code and that no XML doc states. From round 15 on, such findings no longer block #542; they are collected here instead, so the documentation PR can close while the list stays visible.
Each item names the member, what happens, and where the evidence comes from. Items marked lead were measured by a review lens and have not been reproduced independently yet; reproduce before writing any sentence.
Undocumented behaviour
LayoutImage.Height: a finite height taller than the content area makes the save throw the generic too-tallInvalidOperationException. The exception tag names zero, sub-5e-6 and non-finite heights only.PieChart.DiameterandLineSeparator.LineWidthdocument the equivalent for their own members. (lead, round 15 contract C)Document.Language: the XMPdc:languagecopy differs from/Lang. C0 controls other than tab, line feed and carriage return are dropped, a lone surrogate becomes U+FFFD, and a value that becomes empty after that is written as an empty entry.Document.Infonow documents the same XMP behaviour for its entries. (lead, round 15 contract A)SetPdfAOutputIntent/UseCmykOutputIntent: the identifier and info bytes are written as Latin-1 (documented), but ISO 32000-2 Table 401 types both as text strings, which readers decode as PDFDocEncoding. A caller's U+00A0 reads back as €; U+0080 to U+009F read back as other characters. (lead, round 15 contract A; clause read from the local EC3 copy)- WinAnsi-unused codes in standard-14 faces: U+007F, U+0081, U+008D, U+008F, U+0090 and U+009D measure zero in the Helvetica and Times faces, while ISO 32000-2 Annex D note 3 says unused WinAnsi codes above 40 map to the bullet, and poppler draws a 350-unit bullet for each. Lines holding them can overrun their area, justified or not. Affects
TextStyle.MeasureString,FontReference.MeasureStringand theRunningBand.TemplateAttention paragraph. The kernel comment onStandard14Metrics.GetWidthsays measured and rendered widths agree, which does not hold for these codes. (lead, round 15 contract B) ParagraphRenderer(Paragraph, int startLine): astartLinenearint.MinValueoverflows_lines.Count - _startLine, soLayoutreturns Nothing and the save throws the too-tallInvalidOperationExceptioninstead ofArgumentOutOfRangeExceptionfromDraw. The Do-not paragraph already covers the input. (lead, round 15 contract C)TextStyle.LinkUri: a linked run holding only white space writes no link annotation. (lead, round 12 contract B)
Internal comments found false
DocumentRendererprivate comment (around line 665): U+007F measuring zero "in every face" is false for Courier (600 units).
New items found after #542 merges go below.
Metadata
Metadata
Assignees
Labels
No labels
Activity
Tim81 commentedon Sep 19, 2026
Round 16 addition (contract lens A, measured on 361ac49; lead, not yet reproduced independently):
Document.Info(andDocument.Language) → ill-formed XMP for U+FFFE / U+FFFF.XmpMetadataWriter.XmlEscape(src/VellumPdf.Kernel/Document/XmpMetadataWriter.cs:154-171) drops only C0 controls, soTitle = "a�b"is written into the XMP packet as61 EF BF BE 62(U+FFFF likewise asEF BF BF). XML 1.0's Char production excludes both;XmlDocument.LoadXmlon the packet fails with "hexadecimal value 0xFFFE, is an invalid character"./Infois written as given. Measured on Title only; the same escape serves the other Info entries andLanguage. veraPDF not run on it.Tim81 commentedon Sep 19, 2026
Round 16 additions (contract lens C, measured on 361ac49 on a 300×300 page with 20pt margins; leads, not yet reproduced independently):
Paragraph(type remarks): a CR ending one run and an LF starting the next are two line breaks. A CRLF inside one run is one.[a\r\nb]puts b at y258;[a\r | \nb]puts it at y246, one extra empty line;[a | \r\nb]and[a\r\n | b]put it at y258.Paragraph.Textreadsa\r\nbin every case. Source:WordWrapnormalises CRLF per run (run.Text.Replace("\r\n","\n"), ParagraphRenderer.cs:583).["\n\n"@50, "x"@10]and["x"@10, "\n\n\n"@50]both take 36 (3 × 12). Source: ParagraphRenderer.cs:92-104, a max over fragments with the default only when there are none. No XML doc states the uniform per-paragraph line height."\n\n": the item takes 4.8, not 28.8, and nothing carries to the next page. With 25pt left the second line does carry. Source: ListRenderer.cs:126-149 (the item proceeds unless both marker and content are Nothing; itemH = max of the two).docs(layout): apply review round 16; scope paths, links and overprint
Tim81 commentedon Sep 19, 2026
Round 17 of #542's review, run on 215f52e, found the leads below in behaviour that already ships. Each one comes from a reviewer's probe against that head, on Windows. I have not reproduced them myself, so treat them as leads until someone measures them again. The last one is a reading of the source, with no probe behind it.
Paths (Windows)
existingDir + @"\ "or@"\..."),LoadTrueTypeFont,LoadTrueTypeFontAsync,Save(string)andSaveAsync(string)all throwDirectoryNotFoundExceptionnamingexistingDir\. Windows strips trailing spaces and dots. That makes the tag "The directory named in path does not exist" false here.Save(string)andSaveAsync(string)with@"\\?\ "throwFileNotFoundException. Neither member lists that type. It is anIOException, so theIOExceptiontag still catches it.Symbol and ZapfDingbats (#470 neighbours)
abcdefghijklmnop qrstuvwxyz, cell 1's text starts at x=89.805. The Helvetica control is x=173.012, with cell 0 wrapped to 3 lines.TextStyle.LinkUrion a Symbol run. The annotation gets a zero-width rectangle, so it covers none of the text:/Rect [72 755.49 72 769.89]. The Helvetica control is[72 755.49 124.704 769.89].•is written as WinAnsi byte 0x95, which neither font's built-in encoding defines, so poppler extracts nothing. NoTextEncodingWarningis recorded for it. More generally, layout text in these faces goes through the fonts' built-in encodings, soacomes out as α or ❁.Lists and cells
"\n\n"at 30pt splits across a page. On page 2 the next paragraph then starts 21.6pt lower than the drawn content accounts for. With"\n\n\n"the gap is 7.2pt." a"draws(a)and"a "draws(a ). A running band keeps the leading space:( a).Kernel (read from source, not measured)
PdfDocumentwrites annotations only for its own pages (PdfDocument.cs:738-751). ADrawContextbuilt by hand around a page from another document would therefore drop its annotations without an exception.docs(layout): apply review round 17; tag font save errors
Tim81 commentedon Sep 19, 2026
Round 18 of #542's review, run on 846f021, found three more leads in behaviour that already ships. A reviewer's probe measured each one against that head on Windows. I have not reproduced them myself.
A font whose
head.unitsPerEmis 0 measures at an enormous widthFontReference.MeasureStringandTextStyle.MeasureStringreturn an enormous finite width and throw nothing:"abc"at 12pt measures 77,309,411.292.TrueTypeFontEmbedder.GetAdvanceWidthcomputes(int)Math.Round(w * 1000.0 / 0), which saturates toint.MaxValue. Layout then runs at those widths until the save throwsArgumentException [value].UseTrueTypeFont. The measurement is not.Font size ≤ 0 in a paragraph, heading or list item
TextStyle.Defaultleading.ParagraphRenderer.cs:103-104, which falls back to 14.4pt whenever the largestEffectiveLeadingis ≤ 0."a\nb\nc"at size 0 or -10 puts its baselines 14.4 apart, and the next paragraph lands where it would at size 12.Font size ≤ 0 in a table cell
TableRenderer.cs:138).TableRenderer.cs:265, and the next paragraph starts where the table beganTextStyle.FontSizesays "Below zero the glyphs are inverted". That text is on main from docs(layout): correct #503's boundary documentation across four rounds #526, and the -10 cell above contradicts it.docs(layout): apply review round 18; scope links, indent and wrap
docs(layout): apply review round 19; tag null pages, scope crop-box link
Tim81 commentedon Sep 19, 2026
Round 19 of #542's review, run on 3e0e6a8, found four more leads in behaviour that already ships. Each was measured by a reviewer's probe on Windows against that head, except where the item says source read only. I have not reproduced them myself.
A non-finite
DrawContext.PageBounds.Heightrefuses every annotation and outline entry the context registersToPdfYandToPdfRectcomputePageBounds.Height - layoutY, so a non-finite height makes the written coordinate non-finite even when the box andlayoutYare finite.AddUriLinkAnnotation(new LayoutBox(10,10,20,20), "https://x")andAddOutlineEntry("t", 0, 10)both end inArgumentExceptionnaming the non-finite value.DrawContextyou construct yourself. The<exception>tags scope their condition to the caller's argument, and thePageBoundsremarks say only "Stored without a check".A table cell past the resolved column count is never style-checked
TableRenderer.cs:129breaks oncol >= _colWidths.LengthbeforeLayoutValidation.ValidateStyleat:134. It needs an earlier cell'sColSpanto consume the row.TextStyle.FontSizesays "A table cell or list item is checked whatever its text holds".The unnamed-
Standard14IndexOutOfRangeExceptioncomes from font registration during serialisation, and an empty cell reaches it where an empty paragraph does not(Standard14)99andDocument.Save(MemoryStream). The stack for a paragraph, list item, cell, heading and footer band ends inPdfDocument.RegisterStandard14Fonts(PdfDocument.cs:1425), not in aSetFontcall.new Paragraph("", style)andnew Paragraph(" ", style)do not throw, becauseParagraphRenderer.Drawskips a line with no fragments and never registers the font.new Cell("") { Style = style }in a one-cell table throws. The bad style on a grandchild list item does not throw.A centred line that mixes Helvetica and Symbol is placed as if the Symbol run had no width, but only the Symbol run
"HELLO"in Helvetica followed by"HELLO"in Symbol, centred, emitsTmx = 276.298 and 318.982. 276.298 is 297.64 minus half of (39.35 + 3.336), so the line is centred on the Helvetica run plus the inter-run space, and the Symbol glyphs hang past the centre.TextStyle.FontRefscopes "as if it had no width" to a paragraph set wholly in Symbol or ZapfDingbats; the mixed case has no sentence.docs(layout): apply review round 20; scope zero-width lines, indent
Tim81 commentedon Sep 19, 2026
Found by probing during review round 20 of #542, on
5847721(fixes inade6f61). The PR documents none of these as a rule, and none of them blocks it. Measured on A4 with 72pt margins.1. A finite negative
ListElement.Indentcan write-Infinityinto the text matrix, silently, when its gutter overflows and the text has no link.ListElement.Marginsleft -1e308: saves, writing1 0 0 1 -Infinity 743.49 Tm (Child text) Tj.Document.Marginsleft -1e308 and right +1e308: saves, writing-Infinity 757.89 Tm.ArgumentExceptionat save. The member now says so.ListRenderer.cslines 338 and 350-351 (the flat override reverts the gutter to the raw indent), and 396 (the nested gutterMath.Max(indent * 2, indent + childMarkerWidth)is added to the list's left edge).2.
DrawContext.UseEmbeddedFont: the order of its null failures is not stated.RendererContextbuilt with a null document throwsNullReferenceException.RendererContext.RegisterEmbeddedFontUsagetags that;DrawContext.UseEmbeddedFontdoes not.RendererContext's page null, a null handle throwsArgumentNullException(ParamNamekey), not theNullReferenceExceptionthe handle tag names.NullReferenceExceptionwins.PdfDocument.RegisterEmbeddedFontUsage(PdfDocument.cs:254-261): the null document fails first, thenTryGetValue(page), thenhandle.ResourceName.3.
DrawContext.AddOutlineEntryon a context built with a null page: which exception surfaces depends on evaluation order in the save.NullReferenceException.layoutYgivesArgumentNullException(ParamNamekey), not the taggedArgumentException. It still derives from it.PdfDocument.cs:FromUnicode(Title)at 1851, thenpageRefMap.TryGetValue(DestPage)at 1854, thennew PdfReal(DestTop)at 1859.4. An unnamed
ListStylevalue marks nested children with the top-level bullet•, not◦.ListRenderer.cs:381-383uses"◦"only forListStyle.Unordered; otherwiseFormatMarker, whose default arm returns"•"(ListElement.cs:255).5.
LayoutImage.Heighttoo tall for the page.Height = 10000or1e308(withWidth100, orWidthnull) throws the too-tallInvalidOperationException, which is tagged.Widthremarks name their own too-tall case.6.
LineSeparatorRenderer.Layoutdoes not say that a separator taller than its area returnsNothingand that the save then throws the too-tallInvalidOperationException.LayoutImageRenderer.LayoutandPieChartRenderer.Layoutboth say it.LineSeparator.Marginswith Top = Bottom = 1e308. Source:LineSeparatorRenderer.cs:50.7. Follow-up to comment 1's
Document.InfoU+FFFE entry, which said "veraPDF not run on it". It has now been run.Conformance = PdfA2b,Info.Titleset to "a", U+FFFE, "b", one Helvetica paragraph. The fixture was checked first: its XMP holds<rdf:li xml:lang="x-default">a EF BF BE b</rdf:li>.Title = "ab".--flavour 2b:XMPException: XML parsing failure.Tim81 commentedon Sep 20, 2026
Round 21 (2026-09-20), non-blocking behaviour found while probing
Measured on
docs/layout-xml-completeate84a2e8, one probe assembly per lens, exception type andParamNameasserted, PDFs decoded with qpdf 12.4.1.DocumentRenderer.BandTruncationsreturns a fresh list on every get. It allocates a new listper call, so two reads are never reference-equal and a caller cannot compare them to detect a
change. No member says so. (Read from source, not probed.)
Document.Save(Stream)andSaveAsync(Stream)answer a closed destination with differenttypes. A disposed
MemoryStreamgivesArgumentExceptionwithParamNamestream("Streammust be writable") from the synchronous save, and
ObjectDisposedExceptionfrom theasynchronous one, which documents it. A caller writing one
catchfor both meets two types.A
RendererContextwhoseRegisterImageXObjectthrew has already consumed the resourcename. After the throw the image sits in the name cache and the counter has advanced, so the
next different image is registered as
Im2although nothing was ever registered asIm1.RegisterImageXObjectstops throwing on a repeat call. With a null page the first callraises
ArgumentNullException(key)and a second call with the same image returns the cachedname and raises nothing. The remarks state the mechanism but not that the throw disappears.
A flat list whose indent sits just below its area width hard-breaks to one glyph per line and
splits across pages. At an area width of 451.28 an indent of 451.2799 draws
(P)(a)(r)(e)(n)one glyph per line; at 451.28 the item text is discarded and only the marker is drawn. Not filed
as a doc defect:
ListElement.Indentalready tells callers to stay well below half the areawidth.
An internal comment in
DocumentRendereris false for Courier. It says U+0000–U+001F, U+007Fand WinAnsi's five undefined codes measure zero "in every face". In the Courier faces U+007F and
every C1 control measure 600 units; embedded Arial measures 750 for all 32 C0 codes. This
belongs with the existing "internal comments found false" entry.
docs(layout): name the remaining public boundaries (#510) (#542)
Tim81 commentedon Nov 26, 2026
A documentation gap found while writing a PDF/A-2u sample with the Layout API alone: nothing in the Layout docs
says that a document with
Conformanceset to a PDF/A level gets the built-in sRGB output intent without anycall. The Kernel writes it whenever
Conformanceis notNone(src/VellumPdf.Kernel/Document/PdfDocument.cs:76-78, and line 2078,
_outputIntentProfile ?? SrgbIccProfile.Bytes).Document.SetPdfAOutputIntentandUseCmykOutputIntentcarry remarks about replacing or adding an intent, anddocs/layout-guide.md lists them under "CMYK / ICC output intents", so a reader looking for how a PDF/A file gets
its intent finds the setters and no statement of the default. The sample's first version called
SetPdfAOutputIntent(IccProfiles.Srgb, 3, "sRGB"), which only replaced the default identifier("sRGB IEC61966-2.1") with a vaguer one; veraPDF 2u and qpdf passed without it.
Suggested wording on both setters and in the guide: "A PDF/A document gets the built-in sRGB intent by default.
Call this only to replace it."