attach_files
Attach files to the output PDF
Usage
pdftl
<args>output<file>[<option>...]
Details
Attach one or more files to the PDF, either at the document level or associated with specific pages.
The command works by reading a list of arguments from left to
right. Keywords like to_page and relation apply to all the
filenames that came just before them.
Keywords
to_page <page_spec>
Attaches all preceding files (since the last command) to the specified
page(s) as clickable icons. <page_spec> can be a single page (1), a
range (5-10), or a qualifier (even, odd). See also the help
topic [[page_specs]].
relation <type>
Sets the metadata relationship for ALL preceding files (since the last
command). This defines the files’ purpose. Valid <type> values are:
Source, Data, Alternative, Supplement, Unspecified.
PROMPT
This keyword can be used in place of a filename or <page_spec>, in
order to be prompted interactively.
Default Behavior
If a file is listed without a to_page keyword following it, it will
be attached at the document level (visible in the “Attachments” panel
of a PDF reader, but not on a specific page).
Examples
Attach a file to the whole document:
pdftl in.pdf attach_files data.csv output out.pdf
Attach a file to a specific page:
pdftl in.pdf attach_files chart.png to_page 5 output out.pdf
Attach multiple files to one page:
pdftl in.pdf attach_files a.pdf b.pdf to_page 1 output out.pdf
Set a relationship for a document-level file:
pdftl in.pdf attach_files code.zip relation Source output out.pdf
Chain multiple commands:
a.pdfandb.pdfare attached to page 1,c.pdfis attached to page 5.
pdftl in.pdf attach_files a.pdf b.pdf to_page 1 c.pdf to_page 5 output out.pdf
Combine
to_pageandrelation: Keywords apply to all preceding files in their group. Botha.pdfandb.pdfare attached to page 1 AND are both set with theDatarelationship.
pdftl in.pdf attach_files a.pdf b.pdf to_page 1 relation Data output out.pdf
Use interactive prompts: Prompt for a file, then prompt for the page.
pdftl in.pdf attach_files PROMPT to_page PROMPT output out.pdf
Tags: in_place, attachments
Source: pdftl.operations.attach_files
Read online: https://pdftl.readthedocs.io/en/stable/operations/attach_files.html
Type: Operation