PDFs can carry embedded files of any type — XML invoices, spreadsheets, Word documents, images, CAD drawings, source code — inside the PDF container, accessible alongside or independently from the PDF's visible pages. This capability is at the heart of modern hybrid document workflows: a single PDF file can be both the human-readable presentation of a document and a machine-readable data package. There are two distinct mechanisms for embedding files in a PDF: PDF/A-3 associated files (using the /AF and /AFRelationship entries defined in PDF 2.0) and file attachment annotations (the traditional mechanism). Both result in embedded binary data within the PDF, but they serve different purposes and are supported differently by viewers and validators.

File attachment annotations vs associated files

File Attachment Annotations are the traditional mechanism, introduced in PDF 1.0. They create a small paperclip or push-pin icon on the page, which opens the embedded file when clicked. The embedded file is stored as an embedded file stream in the document's /EmbeddedFiles name tree, and the annotation references it. /Subtype /FileAttachment — The annotation subtype /FS — File specification dictionary referencing the embedded file stream /Name — Icon type: /Paperclip, /PushPin, /Graph, /Tag /Contents — Tooltip text (the attachment description) File attachment annotations are appropriate when the embedded file is supplementary to the PDF content — for example, a spreadsheet supporting a report's tables, or a CAD drawing alongside a technical specification. Associated Files (PDF 2.0 / PDF/A-3) use the /AF entry, which can appear in the document catalogue, a page dictionary, or any other PDF object that the associated file relates to. The associated file's /AFRelationship entry declares the semantic relationship: /Source — The embedded file is the source from which the PDF was generated /Data — The embedded file provides data represented in the PDF /Alternative — The embedded file is an alternative representation of the PDF content /Supplement — The embedded file supplements the PDF content /EncryptedPayload — The embedded file is an encrypted version of the PDF content (PDF 2.0) /FormData — The embedded file contains submitted form data /Unspecified — The relationship is unspecified Associated files are the mechanism used by ZUGFeRD/Factur-X for embedded XML invoices, and are the appropriate choice whenever the embedded file has a defined semantic relationship to the PDF.

ZUGFeRD and Factur-X: hybrid PDF invoices

ZUGFeRD (Zentraler User Guide des Forums elektronische Rechnung Deutschland) and its French equivalent Factur-X are the dominant use cases for PDF/A-3 associated files. A ZUGFeRD 2.1 / Factur-X invoice is a PDF/A-3 document where: 1. The PDF envelope is a conforming PDF/A-3b (or PDF/A-3a) document with all the usual archival constraints — embedded fonts, no encryption, no JavaScript. 2. The embedded XML file is attached with /AFRelationship /Data — it contains the machine-readable invoice data conforming to the EN 16931 European Invoice Core Data Model. 3. The XMP metadata in the PDF includes extensions that identify the ZUGFeRD profile and version. The XML profiles range from MINIMUM (basic identifying information only) through BASIC, EN 16931 (the full CII D16B compliant profile), and EXTENDED (additional fields for specific industries). The German federal XRechnung standard uses a subset of the EN 16931 profile. Creating ZUGFeRD PDFs: - Java: Mustang Project (open-source) - Python: factur-x library - .NET: ZUGFeRD-csharp - SAP, Oracle, and major ERP systems have ZUGFeRD/Factur-X connectors Validating ZUGFeRD PDFs — Mustang Project Validator (online/offline) validates both the PDF/A-3 compliance and the embedded XML Schematron constraints. veraPDF also validates PDF/A-3 compliance of ZUGFeRD containers.

Scientific and technical embedded file use cases

Beyond invoicing, embedded files in PDFs are used across scientific and technical domains: Academic publishing — Journal publishers increasingly embed supplementary data files (CSV datasets, R scripts, Python notebooks, raw instrument data) inside PDF articles using associated files. The PDF remains the human-readable article; the embedded files provide the underlying research data for reproducibility. Some publishers use PDF/A-3 for this purpose. Engineering documentation — ISO 32000-2 permits embedding STEP (AP214) CAD files, FEM results, and measurement data alongside technical drawings in a PDF. Manufacturers can distribute a single PDF that contains both the drawing and the associated CAD data — receivers with appropriate software can extract and use the CAD data directly. Medical records — CDA/C-CDA clinical documents can be embedded as associated files in PDF/A-3 medical record PDFs, creating a durable archive that is both human-readable (the PDF) and machine-readable (the CDA XML) in a single file. Software deployment packages — Some software distribution workflows embed checksums, digital signatures, or metadata XML files alongside installer PDFs as an integrity verification mechanism. Limitations: - PDF/A-1 and PDF/A-2 prohibit arbitrary embedded file attachments (only ICC profiles and XMP are allowed) - PDF/A-3 specifically adds embedded file capability to PDF/A-2 with the /AFRelationship constraint - Embedded files increase PDF file size; very large embedded files can make PDF viewers slow to open - Some corporate DLP (Data Loss Prevention) systems flag PDFs with embedded files as potential data exfiltration vectors