Specifically, the manipulatePdf function: 
  
        PdfDictionary action = field.getAsDict(PdfName.A);
        PdfDictionary f = action.getAsDict(PdfName.F);
        f.put(PdfName.F, new
PdfString("http://itextpdf.com:8080/book/request";);

Your code is presumably looping through every object in the PDF, looking
for one that contains the string "/Filespec".  That could work, but you
don't know if the file specification is its own object, or part of
something else.  File speicifcation dictionaries are not required to be
top level objects, so just because you see /FileSpec doesn't mean you
know now to it out of your "obj".

You say this is a link in a PDF collection.  In THIS PARTICULAR CASE, it
sounds like you can safely use that technique.  As soon as your PDFs
start coming from different sources, or the file isn't part of a
collection, all bets are off.

To generalize your code a little more, I suggest the following... You'll
have to forgive my Java, I no speaky VB.net.

   if (obj.isDict()) {
     PdfDictionary dict = (PdfDictionary) obj;
     if (dict.getType() == PdfName.FILESPEC) {
       PdfString oldSpec = dict.getAsString(PdfName.F);
       String specStr = oldSpec.toString();
       String newSpecStr = modifySpecStrSomehow(specStr);
       dict.put(PdfName.F, new PdfString( newSpecStr );
     }
   }
 
--Mark Storer
  Senior Software Engineer
  Cardiff.com
 
import legalese.Disclaimer;
Disclaimer<Cardiff> DisCard = null;
 
 


________________________________

        From: 1T3XT BVBA [mailto:[email protected]] 
        Sent: Thursday, March 24, 2011 8:53 AM
        To: [email protected]
        Subject: Re: [iText-questions] modify pdf objects with iText
        
        
        Op 24/03/2011 15:38, [email protected] schreef: 

                Hi,
                
                I would like to know if is possible to modify pdf object
and re-save the pdf with changes.
                


        This is an example that shows how to replace an URL:
http://1t3xt.be/?124
        If you want to know more about the structure and the content of
the objects, you need to read ISO-32000-1.
        


------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to