Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
PDF files can have attachments added at the document or page level. The technical foundations of PDF attachments are discussed in Chapter 7. To add an attachment at the file level:
pdftk input.pdf attach_files file1.xls file2.xls output output.pdf
The attachment is added to the end of the list of file-level
attachments. To add an attachment at the page level, use the to_page keyword:
pdftk input.pdf attach_files file1.xls to_page 4 output output.pdf
To extract the attachments from a document, writing them to a given
directory, we can use the unpack_files
keyword:
pdftk input.pdf unpack_files output outputs/
This writes the attachments, under their original filenames, in the outputs directory.