Attachments
The attachments list embeds files inside the generated PDF. Each file is stored within the PDF, associated with the document, and can be extracted by readers that support PDF attachments (most desktop PDF viewers).
Properties
Each entry of attachments takes:
| Property | Type | Default | Description |
|---|---|---|---|
filePath | string | — | The file to embed, a path beside the document. Required |
fileName | string | the file's own name | The name the file carries inside the document |
description | string | the file name, with a notice | What the file is, shown in a viewer's attachments panel |
relationship | string | data | What the file is to this document: source, data (behind a table or chart), alternative (another rendering, such as an e-invoice's XML), supplement, schema, formData or unspecified |
mimeType | string | from the file extension, application/octet-stream when it is unknown | Media type of the file as type/subtype, such as "text/csv", with no parameters |
A document may carry several files, each stating its own relationship. schema and formData are PDF 2.0 names: in a 1.7 file they are written as unspecified, with a notice, so set metadata.pdfVersion to "2.0" to keep them.
Examples
Attach a CSV data file
{
"document": {
"attachments": [
{
"fileName": "revenue_data.csv",
"filePath": "attachments/revenue_data.csv",
"description": "Raw revenue data used to generate this report",
"relationship": "data"
}
],
"content": [
{ "p": "See the attached CSV file for the underlying data." }
]
}
}
Attach supporting documentation
{
"document": {
"metadata": {
"title": "Shipping Manifest",
"author": "Logistics Team"
},
"attachments": [
{
"fileName": "customs_declaration.pdf",
"filePath": "attachments/customs_declaration.pdf",
"description": "Customs declaration form for cross-border shipment",
"relationship": "supplement"
}
],
"content": [
{ "p": "This manifest includes the customs declaration as an attachment." }
]
}
}
Archival and accessibility
An attachment changes the archival claim the PDF makes by default: PDF/A-3b instead of PDF/A-2b, or PDF/A-4f instead of PDF/A-4 on PDF 2.0, the levels that admit embedded files. A PDF/UA-2 claim requires a description on every file. See Conformance.
To encrypt the attached files alone and leave the document readable, set encryption.encryptEmbeddedFilesOnly (see Encryption).
Uploading the files
Upload a file to embed to your workspace's attachments folder, then name it by that path:
POST /v1/{tenantId}/assets/attachments
Content-Type: multipart/form-data
file: revenue_data.csv
The folder takes .xml, .xsd, .csv, .json, .txt and .pdf files up to 5 MB. A file that is not found is reported as ATTACHMENT_NOT_EMBEDDED in the response's errorCodes.
Where attachments appear
Attached files are accessible through the PDF viewer's attachments panel (sometimes called "paperclip" panel). In Adobe Acrobat, navigate to View > Show/Hide > Navigation Panes > Attachments. To open the document on that panel, set metadata.viewerPreferences.pageMode to useAttachments (see Links and navigation).
In a DOCX
A DOCX carries no attachments. Each file is reported with a WARNING naming its file name, media type, relationship and description, and left out.