Hi,
I'm new to this list but have a question which I don't think has been
resolved here in my searches through the archives.

I'm trying to remove attachments from a number of my pdf files (I can
extract via pdftk, so preserving them is not an issue).

I found the following example code on the mailing list from a 
http://old.nabble.com/Remove-Attachments-from-pdf-file-td22804697.html
previous thread :
public void removeAttachments(PdfReader reader) {   
        PdfDictionary catalog = reader.getCatalog(); 
        PdfDictionary names =
(PdfDictionary)PdfReader.getPdfObject(catalog.get(PdfName.NAMES));   
        if( names != null)   { 
         PdfDictionary files = (PdfDictionary)
PdfReader.getPdfObject(names.get(PdfName.EMBEDDEDFILES));   
                if( files!= null ){   
                        for( Object key : files.getKeys() ){ 
          files.remove((PdfName)key);         
                        } 
         reader.removeUnusedObjects(); 
         }   
        } 
} 
However, the code does not work.    In my introspection of the code, I only
found that the variable "names" is null.  On further examination, even
"catalog.get(PdfName.NAMES)" shows null on a System.out.println().

Before I spend days diving deep into the itext library and PDF spec, I was
wondering if someone could help me in figuring out what I can do to get this
working.

Thanks in advance!


-- 
View this message in context: 
http://itext-general.2136553.n4.nabble.com/Remove-pdf-attachments-tp2172927p2172927.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------

_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to