Skip to content

Kernel: write file specifications and embedded file streams #242

Open

Description

@Tim81

Attachments are the clearest capability gap in the library. /EmbeddedFile and /Filespec appear
only in VellumPdf.Conformance — where they exist to validate other people's files
(EmbeddedFileRule.cs, EmbeddedFilePdfaRule.cs, UaEmbeddedFileRule.cs). The writer cannot produce
one, and VellumPdf.Reader recognises /Type /EmbeddedFile in exactly one place —
CryptFilterResolver.cs:170-182 — solely to decide whether the /EFF crypt filter applies.

Scope

File specification dictionary (7.11.3, Table 43): /Type /Filespec, /F and /UF — both,
since /UF is the Unicode form every modern reader prefers and PDF/A rules already check for it —
plus /EF, /Desc, and /AFRelationship (A4).

Embedded file stream (7.11.4, Table 44): /Type /EmbeddedFile, /Subtype carrying a MIME type
per RFC 8118, /Params with /Size, /CreationDate, /ModDate and /CheckSum, and PDF 2.0's
embedded-file thumbnails.

Must not emit /DOS, /Mac or /Unix. ISO 32000-2 clause 0.3 deprecates OS-specific file
specifications. The validator already enumerates them when reading (EmbeddedFilePdfaRule.cs:106-108)
— that is correct for a reader and wrong for a writer.

/Desc deserves a note: PDF/UA-2 §8.14.1 makes it required on every file specification in the
EmbeddedFiles name tree, so the API should make it hard to omit rather than merely allow it.

Guidance from the PDF Association

AN002 ("Associated Files") §6.1 recommends embedding rather than referencing — "in almost all
contexts, only embedded files make sense" — and warns that registering the same file in both the
EmbeddedFiles name tree and a file attachment annotation makes some viewers display it twice:
"strongly advised to use either one or the other". The API should make that an explicit choice rather
than something a caller discovers from a bug report. That constraint belongs to A3 but is decided here.

Acceptance

  • Attach a file, read it back through VellumPdf.Reader, byte-identical.
  • /F and /UF both present and consistent; /Desc present; /Subtype a valid RFC 8118 type.
  • /Params /CheckSum verified against the actual bytes.
  • No /DOS, /Mac or /Unix in the output — asserted, not assumed.
  • qpdf --check clean, and the attachment is visible to pdfdetach -list.

Relates to

  • A1 — the name tree this lives in.
  • A3 — file attachment annotations, the other placement.
  • A4 — associated files; an embedded file becomes an associated file by being referenced from /AF.
  • A5 — PDF/A-4F needs /AFRelationship, which needs this.
  • Conformance: PDF/A §6.8-5 — recursive validation of embedded PDF/A-1 files #140 — recursive validation of embedded PDF/A files, which has never had a producible fixture.

Plan labels used above, resolved: A1 #241 · A4 #243 · A3 #245 · A5 #246.

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

    type/feature

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions