Takumi

Attachments

Embed files in PDF documents and configure PDF/A-3 attachments for electronic invoices.

Pass files through attachments to embed source data, supporting documents, or invoice XML. Viewers with an attachment panel list them there:

Attachments
import {  } from "takumi-pdf";

const  = await (, {
  : [
    {
      : "factur-x.xml",
      : ,
      : "application/xml",
      : "Factur-X invoice data",
      : "alternative",
    },
  ],
});
FieldValue
nameFile name in the PDF. Two attachments cannot share a name.
dataA Uint8Array, or a string written as UTF-8
mimeTypeIANA media type, such as "application/xml"
descriptionHuman-readable description
relationshipThe file's role, written as AFRelationship. See the next table.
modificationDateUTC YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS. Falls back to metadata.creationDate.

relationship takes one of these values:

ValueMeaning
"source"The document was created from this file.
"alternative"An alternative representation of the document.
"data"The file backs a visual presentation in the PDF.
"supplement"Additional resources for the document.
"unspecified"No clear relationship. The default.

Electronic invoices

For a Factur-X or ZUGFeRD document, use PDF/A-3 and attach the invoice XML:

Electronic invoices
import {  } from "takumi-pdf";

const  = await (, {
  : "3b",
  : { : "Invoice 1042", : "2026-08-06" },
  : [
    {
      : "factur-x.xml",
      : ,
      : "application/xml",
      : "Factur-X invoice data",
      : "alternative",
    },
  ],
});

The PDF/A-3 levels require three fields on each attachment:

  • mimeType
  • description
  • a modification date from modificationDate, or the metadata.creationDate fallback

TypeScript enforces mimeType and description under these levels. A missing date fails the render.

Levels that allow attachments

pdfaAttachments
unsetAllowed
"3b", "3u", "3a"Allowed, with the three fields above
"4f"Allowed, with mimeType and description. The PDF 2.0 option.
"2b", "2u", "2a", "4"Not allowed: a TypeScript type error

Attaching the XML does not validate it or its profile. Add the profile's XMP metadata and validate the result as described in Invoices.

Last updated on