PdfDictionary catalog = reader.getCatalog();
PdfDictionary names = (PdfDictionary) PdfReader
.getPdfObject(catalog.get(PdfName.NAMES));
if (names != null) {
PdfDictionary embFiles = (PdfDictionary) PdfReader
.getPdfObject(names.get(new PdfName("EmbeddedFiles")));
if (embFiles != null) {
HashMap embMap = PdfNameTree.readTree(embFiles);
for (Iterator i = embMap.values().iterator(); i.hasNext();) {
PdfDictionary filespec = (PdfDictionary) PdfReader
.getPdfObject((PdfObject) i.next());
unpackFile(reader, filespec, outPath);
}
}
}
for (int k = 1; k <= reader.getNumberOfPages(); ++k) {
PdfArray annots = (PdfArray) PdfReader.getPdfObject(reader
.getPageN(k).get(PdfName.ANNOTS));
if (annots == null)
continue;
for (Iterator i = annots.listIterator(); i.hasNext();) {
PdfDictionary annot = (PdfDictionary) PdfReader
.getPdfObject((PdfObject) i.next());
PdfName subType = (PdfName) PdfReader.getPdfObject(annot
.get(PdfName.SUBTYPE));
if (!PdfName.FILEATTACHMENT.equals(subType))
continue;
PdfDictionary filespec = (PdfDictionary) PdfReader
.getPdfObject(annot.get(PdfName.FS));