read filename of attachments in a portable collection
Submitted by account3321 on Thu, 06/21/2012 - 13:50
My duty is: find all kinds of attachments in pdf files
After studying the examples I was able to detect the document-level and page-level attachments
programmatically.
But how do I detect the filename of attachments that are organized in a portable collection?
In the listings 16.9 - 16.14 is described how to create portable collections.
I could not found any stuff about analyzing the content of a portable collection.
- Login to post comments
Content © 2010 1T3XT BVBA

Use iText RUPS to find out where the file names are
Submitted by Bruno Lowagie on Sat, 06/23/2012 - 15:19.Hello,
if you don't find some aspect of the PDF that you need to extract from the document, the best way to solve the problem is to use iText RUPS to discover how to reach it using code.
For instance:
- if you have file attachment annotations, you know that you need the /Annots array from the page dictionary. This /Annots array will contain reference to annotation dictionaries. In the case of file attachments, they'll be of /Type /Filespec. There will also be an /FS entry (FS = File Specification). In that /FS dictionary, there may be an /F and/or /UF entry. That's where you'll find the file name (if it's available).
- if you have document level annotations, you need to find the /EmbeddedFiles entry in the /Names entry of the root object of the PDF. The /EmbeddedFiles dictionary contains a /Names array that consists of a series of String values and /Filespec dictionaries. Again you'll find an /F and/or /UF entry in those file specification dictionaries (if a name was defined for the attachment).
It's quite easy to achieve with what is available in chapter 13.