Extract Embedded File Attachments From a PDF
PDF attachments are complete files stored inside a PDF's EmbeddedFiles name tree, invisible on the pages themselves. This tool walks that tree to list and extract every embedded file, and can also attach files of your own to a PDF, with all processing done locally in your browser.
The most common reason anyone needs this today is electronic invoicing. Hybrid formats like ZUGFeRD and Factur-X are ordinary, human-readable invoice PDFs that carry the machine-readable XML invoice as an embedded attachment — the mechanism this tool exposes directly. If a supplier sent you such a PDF and your accounting software wants the raw XML, extract it here; if you want the full background on the formats, see the electronic invoicing guide. The same panel works in the other direction: pick any PDF, choose files with the file picker, and download a copy of the PDF with those files embedded — useful for shipping source data, terms, or a spreadsheet alongside a report in a single file.
How it works
The PDF specification stores document-level attachments under the catalog's /Names dictionary, in a branch called /EmbeddedFiles. That branch is a name tree: a sorted, possibly multi-level structure of nodes whose leaf entries pair a string name with a file specification dictionary. Name trees exist so a document with thousands of entries can be searched without loading everything, which means a correct reader cannot just look at one array — it must recursively walk /Kids nodes and merge their /Names arrays. That walk is exactly what this tool does, so attachments are found even in deeply nested trees.
Each leaf points to a file specification (/Filespec) holding the filename (/F and the Unicode variant /UF) and an /EF entry that references the actual embedded file stream. The stream contains the attachment's raw bytes, usually Flate-compressed, plus optional metadata: MIME subtype, size, modification date, and an MD5 checksum. Extraction resolves the stream, inflates it, and hands you the original bytes under the original filename — a lossless round trip, since the PDF stores the file verbatim rather than converting it.
Attaching runs the same machinery in reverse with pdf-lib: the chosen file's bytes become a new compressed stream object, a file specification is written around it, and its name is inserted into the EmbeddedFiles tree (creating the tree if the PDF has none). The pages, fonts, and existing content are untouched; the document simply gains objects. One caveat worth knowing: some strict profiles constrain attachments — PDF/A-2 permits only PDF/A attachments, while PDF/A-3 (the basis of ZUGFeRD and Factur-X) exists precisely to allow arbitrary ones.
Worked example: unpacking a Factur-X invoice
A supplier invoice arrives as invoice-2026-0714.pdf, 312 KB, one visible page. Loaded into this tool, the attachment list shows a single entry: factur-x.xml, 14.2 KB, subtype text/xml. Extraction is instant and yields the EN 16931-structured XML that an ERP system can import without any OCR or retyping — the visible page and the XML are two renditions of the same invoice. Reversing the flow: attaching a 96 KB terms-and-conditions PDF and a 41 KB pricing XLSX to a 480 KB report produces one 619 KB file — 2 KB of structural overhead beyond the raw sizes, since the attachments were already compressed formats that Flate cannot shrink further.
Frequently asked questions
How do I get the XML invoice out of a ZUGFeRD or Factur-X PDF?
Load the PDF here and the embedded XML, usually named factur-x.xml or zugferd-invoice.xml, appears in the attachment list for download. That XML is the machine-readable invoice that accounting software actually processes.
Why can I not see any attachments when I open the PDF normally?
Attachments live in the document's EmbeddedFiles name tree, not on the pages, so they are invisible unless your viewer has an attachments panel and you open it. Many browsers' built-in PDF viewers simply do not show them.
What kinds of files can be attached to a PDF?
Any file type: spreadsheets, XML, images, ZIP archives, even other PDFs. The PDF format stores the attachment as an opaque byte stream with a filename, an optional MIME type, and optional metadata like modification date.
Does attaching a file change how the PDF pages look?
No. The file is added to the document's internal name tree and the pages are untouched, so nothing changes visually. The PDF's file size grows by roughly the size of the attached file.
Are extracted attachments safe to open?
Treat them like email attachments: a PDF can embed any file, including executables or macro-enabled documents. This tool only extracts on your device and never runs the content, but you should scan unexpected attachments before opening them.