Repository navigation
Description
The PDF version VellumPdf writes is not a caller decision. It is inferred from one thing —
PdfDocument.cs:600-604, and identically at :996 and in WriteLinearizedHeader at :1663:
writer.WriteAscii("%PDF-"u8);
if (Conformance == PdfConformance.None)
writer.WriteAscii("2.0"u8);
else
writer.WriteAscii("1.7"u8);Two versions, chosen by whether a conformance profile was requested. A caller who needs %PDF-1.4
for an archival deposit, or %PDF-1.7 without a PDF/A profile, has no way to ask.
That gap becomes more visible once #222 lands PDF/A-4, because the Conformance == None branch stops
being a reliable proxy for "2.0 is fine".
What is wanted
An explicit PdfVersion on PdfDocument (and the Layout Document), defaulting to 2.0, accepting
1.4 through 2.0. But the header is the easy half, and stamping it alone would be a bug — this
library's whole posture is that a file should not lie about itself.
Declaring %PDF-1.4 while emitting an object stream produces a file that claims a version whose
readers cannot parse it. So the option has to constrain the writer, and where it cannot, refuse
rather than emit something inconsistent. The version-sensitive constructs already reachable:
| Construct | Introduced | Where |
|---|---|---|
| Object streams | 1.5 | PdfDocument.UseObjectStreams (:151), opt-in, default off |
| Cross-reference streams | 1.5 | written alongside object streams |
| Transparency, blend modes, soft masks | 1.4 | canvas alpha / ExtGState |
| JPXDecode (JPEG 2000) | 1.5 | JpxImageLoader |
AES-128 (/V 4, /AESV2) |
1.6 | encryption settings |
AES-256 (/V 5, /R 6, /AESV3) |
2.0 | PdfEncryptionSettings |
Associated files, /AFRelationship, /DPart |
2.0 | not implemented today |
So PdfVersion = Pdf14 should turn UseObjectStreams into a validation error rather than silently
ignoring it, and should reject AES encryption. The precedent for that shape is already in the tree:
UseObjectStreams documents that it "cannot be combined with PrepareForSigning" and throws
NotSupportedException.
The interaction with Conformance needs deciding explicitly rather than by precedence accident: a
profile pins the version (PDF/A-2 ⇒ 1.7, PDF/A-4 ⇒ 2.0, PDF/A-1 ⇒ 1.4 per #218), so setting both to
incompatible values should throw at Save with a message naming both, not quietly pick one.
Reading
The reader already accepts any header — FileHeaderRule is a conformance rule, not a parse gate,
and nothing in VellumPdf.Reader rejects a file on its declared version. That is correct behaviour
for a general reader and it is simply undocumented. Worth stating in the reader guide (#187) that
1.0 through 2.0 are read, and that the header is advisory: real files routinely use constructs from
later versions than they declare, which is why the reader keys on structure rather than the header.
Documentation
None of the above is currently written down anywhere. The README, docs/architecture.md and the
Kernel guide say nothing about which PDF versions are read or written. Add:
- Which versions are read (all of them, header advisory).
- Which versions can be written, and how to ask for one.
- That the default is 2.0, and that requesting a conformance profile pins the version.
- A short table of which features are unavailable at which version, so the constraint errors are
predictable rather than surprising.
Note on advertising
Per the discussion on #222: do not describe this as "PDF 2.0 support" in package descriptions until
the PDF/A-4 profile validates green against veraPDF in CI. Emitting a 2.0 header is not conformance,
and the two claims should not be conflated in user-facing copy.
Relates to
- Conformance: PDF/A-4 (ISO 19005-4) — stop downgrading conformance output to %PDF-1.7 #222 — reworks the same header branch; these should land together or in that order.
- Conformance: PDF/A-1 (ISO 19005-1) rule set — the profile v2.5 is named after #218 — PDF/A-1 pins 1.4, which is the first real consumer of a 1.4 constraint set.
Activity
Tim81 commentedon Aug 29, 2026
Declaring a version constrains what may be omitted, not only what may be emitted
The body treats the version as a constraint on constructs the writer may use — object streams,
AES-256, transparency. There is a second direction, and it is now tracked as #325: ISO 32000-2
clause 0.3 deprecates a set of keys this library currently writes, and it writes them under a
%PDF-2.0header./ProcSeton every page (PdfPage.cs:107),/NeedAppearances(AcroFormBuilder.cs:101), and thefull
/Infoset (PdfDocumentInfo.cs:27-32). None of them is deprecated at 1.7, so the versionselector this issue introduces is exactly what decides whether they are emitted — a caller asking for
%PDF-1.7should still get them.That makes #325 a consumer of this issue rather than a parallel one, and the version-to-feature table
here needs a deprecation column alongside its introduction column.
The table gains rows
Beyond the constructs already listed, from the Arlington PDF 2.0 model and clause 0.3:
/NS,/RoleMapNS/SD/UseBlackPtComp,/HTO/AF,/AFRelationship/L/Measure,/PtDataon XObjects/V6 //R7/AuthCode,/KDFSaltThe last two are worth calling out: they are extensions to PDF 2.0 rather than part of it, so they
are declared through a developer extensions dictionary (#235) rather than by the header version. The
version selector needs to know the difference.
A third source of the same constraint
ISO/TS 32005 §5.1 independently requires that a document using structure namespaces "shall be
versioned as PDF 2.0 using either the header or the value of the
Versionentry in the documentcatalog dictionary". So the tagged-PDF work in #271 pins the version too, by a different route.
Downstream
The version-to-feature table built here becomes the input to the auto-upgrade policy in the v3.x
editing line — ISO 32000-2 Annex I requires that a writer never lower a file version and may raise
it when newer features are used, which needs exactly this table to implement.