Skip to main content

Module embedded_files

Module embedded_files 

Source
Expand description

Embedded files and associated files (ISO 32000-1 §7.11, ISO 32000-2 §7.11.4).

Two related PDF features surface here through one EmbeddedFile model:

  • Embedded files — file streams stored inside the PDF and registered in the catalog’s /Names /EmbeddedFiles name tree (the “attachments” panel of a viewer; ISO 32000-1). Each name maps to a file specification dictionary whose /EF entry points at the embedded-file stream.

  • Associated files (/AF) — a PDF 2.0 addition: an array of file specifications attached to the catalog, a page, an annotation, an XObject, etc., each carrying an /AFRelationship that states why the file is attached (/Source, /Data, /Alternative, …). This is the mechanism PDF/A-3 and ZUGFeRD/Factur-X use to embed the source XML of an invoice. PDF 2.0 requires every associated file to also appear in the /Names /EmbeddedFiles tree, so the two lists usually overlap.

This module only parses and exposes metadata and the embedded stream’s object id; it never decodes the (potentially large) payload. Callers pull the bytes on demand via crate::PdfDocument::embedded_file_bytes, which routes through the parser’s filter pipeline (and so respects ParseLimits).

Structs§

EmbeddedFile
One embedded or associated file: the file-specification metadata plus the object id of its embedded-file stream (when it carries one). The payload is not decoded here — fetch it with crate::PdfDocument::embedded_file_bytes.

Enums§

EmbeddedSource
Where an EmbeddedFile was discovered.

Functions§

parse_associated_files
Catalog-level associated files (/Root /AF, PDF 2.0). Empty for most files.
parse_embedded_files
Document-level embedded files from the catalog’s /Names /EmbeddedFiles name tree. Empty when the document declares none.
parse_page_associated_files
Page-level associated files (/Page /AF, PDF 2.0), read off an already-resolved leaf page dictionary. /AF is not an inheritable page attribute, so this looks only at the leaf.