Short answer:
You cannot (currently) add the description of a file attachment when using pdftk
.
(However, it should be not too complicated to add this feature, because it only requires an additional key entry /Desc
to the file attachment dictionary... Maybe you should submit a feature request to the pdftk
developers?)
Longer answer:
You may be able to achieve what you want with the help of (a very recent version of) Ghostscript. But be warned, it is quite complicated!
It requires the usage of the special PostScript extension that defines the pdfmark
operator. This operator was created to insert advanced features into a PDF file which cannot be used within PostScript itself.
I'll demonstrate it with the help of a separate file which uses a series of pdfmark
operations to insert a text file into a PDF. This is the content of text file, mypdfmark-for-attachments.ps
:
[ /NamespacePush pdfmark
[ /_objdef {fstream} /type /stream /OBJ pdfmark
[ {fstream} << /Type /EmbeddedFile >> /PUT pdfmark
[ {fstream} (I only simulate text file content here...)
/PUT pdfmark
[ /Name <feff 0044 005a 005a 005a 005a 005a>
/FS<<
/Desc (dEsCrIpTiOn)
/Type /Filespec
/F (my.txt)
/EF <<
/F {fstream}
>>
>> /EMBED pdfmark
[ {fstream} /CLOSE pdfmark
[ /NamespacePop pdfmark
As you can see, the /Desc
key holds my description text dEsCrIpTiOn
.
Now run this Ghostscript command:
gs -o emb.pdf -sDEVICE=pdfwrite mypdfmark-for-attachments.ps -f some.pdf
Here is a screenshot of the resulting PDF file as shown by Acrobat:
