Info
This site is generated using the static site generator developed by the Typst Community. Please adjust the text content of this banner according to your usage requirements. At Typst GmbH's request, when publishing documentation, you must clearly indicate that it is non-official and display the version of Typst being documented. For details, refer to Issue #874 on typst/typst.
TypstDocumentEnglish
v0.dev.2025-09-12

attach
Element
Element
Element functions can be customized with set and show rules.

A file that will be attached to the output PDF.

This can be used to distribute additional files associated with the PDF within it. PDF readers will display the files in a file listing.

Some international standards use this mechanism to attach machine-readable data (e.g., ZUGFeRD/Factur-X for invoices) that mirrors the visual content of the PDF.

Example

#pdf.attach(
  "experiment.csv",
  relationship: "supplement",
  mime-type: "text/csv",
  description: "Raw Oxygen readings from the Arctic experiment",
)

Notes

  • This element is ignored if exporting to a format other than PDF.
  • File attachments are not currently supported for PDF/A-2, even if the attached file conforms to PDF/A-1 or PDF/A-2.

Parameter
Parameter
Parameters are input values for functions. Specify them in parentheses after the function name.

path
Required
Required
Required parameters must be specified when calling the function.
Positional
Positional
Positional parameters can be set by specifying them in order, omitting the parameter name.

The path of the file to be attached.

Must always be specified, but is only read from if no data is provided in the following argument.

data
Required
Required
Required parameters must be specified when calling the function.
Positional
Positional
Positional parameters can be set by specifying them in order, omitting the parameter name.

Raw file data, optionally.

If omitted, the data is read from the specified path.

relationship
Settable
Settable
Settable parameters can be set using the set rule, changing the default value used thereafter.

The relationship of the attached file to the document.

Ignored if export doesn't target PDF/A-3.

Available string values:
  • source

    The PDF document was created from the source file.

  • data

    The file was used to derive a visual presentation in the PDF.

  • alternative

    An alternative representation of the document.

  • supplement

    Additional resources for the document.

Default value:

none

mime-type
Settable
Settable
Settable parameters can be set using the set rule, changing the default value used thereafter.

The MIME type of the attached file.

Default value:

none

description
Settable
Settable
Settable parameters can be set using the set rule, changing the default value used thereafter.

A description for the attached file.

Default value:

none

Open official docs

Search