demonstr8r wrote:
> 
> I am working on an utility that automates the generation of PDF files with
> attachments using the iText Java library.  So far, I can honsetly say
> using
> iText has saved me a bunch of time and effort. However, I ran into a bit
> of
> a snag this week related to removing and/or overwriting attachments within
> a
> PDF.  Is this supported and if so how?  Any advice is greatly appreciated.
> 

I managed to figure out a partial solution after studying the PdfReader
implemenation on sourceforge.net.  Removing or overwriting a specific
attachment appears to be quite a bit more involved.  If you have a solution
for that, please post it here.

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);
         } 
      }
   }
}
-- 
View this message in context: 
http://www.nabble.com/Managing-PDF-attachments-with-iText-tp21712325p21736471.html
Sent from the iText - General mailing list archive at Nabble.com.


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Reply via email to