cpdf -attach-file <filename> [-to-page <page number>] in.pdf -o out.pdf
cpdf -list-attached-files in.pdf
cpdf -remove-files in.pdf -o out.pdf
cpdf -dump-attachments in.pdf -o <directory>
To add an attachment, use the -attach-file operation. For instance,
cpdf -attach-file sheet.xls in.pdf -o out.pdf
The -to-page option can be used to specify that the files will be attached to the given page, rather than at the document level. The -to-page option may be specified at most once.
To list all document- and page-level attachments, use the -list-attached-files operation. The page number and filename of each attachment is given, page 0 representing a document-level attachment.
$cpdf -list-attached-files 14psfonts.pdf 0 utility.ml 0 utility.mli 4 notes.xls
To remove all document-level and page-level attachments from a file, use the -remove-files operation:
cpdf -remove-files in.pdf -o out.pdf
The -dump-attachments operation, when given a PDF file and a directory path as the output, will write each attachment under its filename (as displayed by -list-attached-files to that directory. The directory must exist prior to the call.
cpdf -dump-attachments in.pdf -o /home/fred/attachments
Unless the -raw option is given, the filenames are stripped of dubious special characters before writing. It is converted from unicode to 7 bit ASCII, and the following characters are removed, in addition to any character with ASCII code less than 32:
/ ? < > ' : * | " ˆ + =