Paulo,

Thanks for he quick reply.
Could you please provide me sample code for reading the pdf and changing
the weblinks to launch type.

Thanks

-neeru


                                                                       
                      "Paulo Soares"                                   
                      <[EMAIL PROTECTED]         To:      Neeru 
Bhardwaj/US-PA-GV/RESEARCH/[EMAIL PROTECTED]
                      e.pt>                    <[EMAIL PROTECTED]>
                                               cc:                     
                      09/14/2004 10:11         Subject: RE: [iText-questions] urgent - 
problem saving the pdfdictionary objects
                      AM                                               
                                                                       
                                                                       




Use PdfStamper.

Best Regards,
Paulo Soares

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of [EMAIL PROTECTED]
> Sent: Tuesday, September 14, 2004 1:25 PM
> To: [EMAIL PROTECTED]
> Subject: [iText-questions] urgent - problem saving the
> pdfdictionary objects
>
>
>
>
>
> I have a pdf which has links defined as weblink and I need to
> change these
> links to launch type links.
> The code below works for some of the links and it is not
> saving some of the
> changes.
> It does not save the links defined at the start of a  new table.
>
> Thanks for your help in advance.
>
> ArrayList l_master = new ArrayList();
>                   int l_f = 0;
>
>                   PdfCopy l_writer = null;
>
>                   l_reader = new PdfReader(a_pdfFile);
>
>                   l_reader.consolidateNamedDestinations();
>                   // we retrieve the total number of pages
>
>                   int l_n = l_reader.getNumberOfPages();
>
>                   List l_bookmarks =
> SimpleBookmark.getBookmark(l_reader);
>                   l_bookmarks = SimpleBookmark.getBookmark(l_reader);
>
>                   if (l_bookmarks != null) {
>                         l_master.addAll(l_bookmarks);
>                   }
>                   // step 1: creation of a document-object
>                   l_document = new
> Document(l_reader.getPageSizeWithRotation(1));
>
>                   // step 2: we create a writer that listens to the
> document
>                   l_writer = new PdfCopy(l_document, new
> FileOutputStream(a_outFile));
>
>                   // step 3: we open the document
>
>                   l_document.open();
>
>                   // step 4: we add content
>                   PdfImportedPage l_page;
>                   for (int l_i = 0; l_i < l_n;) {
>                         ++l_i;
>
>
>                         PdfDictionary l_pg = l_reader.getPageN(l_i);
>                         PdfArray l_arr =
>                               (PdfArray)
> l_reader.getPdfObject(l_pg.get(PdfName.ANNOTS));
>
>                         if (l_arr != null) {
>                               ArrayList l_list = l_arr.getArrayList();
>                         for (int l_an = 0; l_an <
> l_list.size(); ++l_an) {
>
>                                     PdfObject l_obj =
>
> l_reader.getPdfObject((PdfObject)
> l_list.get(l_an));
>                                     if (l_obj != null
>                                           && l_obj.type() ==
> PdfObject.DICTIONARY) {
>
>                                           PdfDictionary l_info =
> (PdfDictionary) l_obj;
>                                           PdfDictionary l_dictionary =
> (PdfDictionary) l_obj;
>                                           PdfName l_key = null;
>                                           PdfObject l_value = null;
>
>                                           String l_uriVal = null;
>
>                                           Iterator l_it =
> l_dictionary.getKeys().iterator();
>                                           while (l_it.hasNext()) {
>                                                 l_key = (PdfName)
> l_it.next();
>                                                 l_value = (PdfObject)
> l_dictionary.get(l_key);
>
>
> //System.err.println("number of elements in set
> ***"+l_key.toString() +
> "::" + l_value.toString());
>                                                 if
> (l_value.isDictionary())
> {
>
> PdfDictionary l_dict
> = (PdfDictionary) l_value;
>                                                       if
> (l_dict.contains(PdfName.URI)) {
>
> //System.err.println("contains
> URI**"+l_dict.get(PdfName.URI).toString());
>
> //l_uriVal =
>                                                             //
> l_dict.get(PdfName.URI).toString();
>
>
> //    Savre the
> Object
>                                                             PdfObject
> l_pdfObject = l_dict.get(PdfName.URI);
>
>                                                             // Remove
> previous settings
>
> l_dict.remove(PdfName.URI);
>
> l_dict.remove(PdfName.TYPE);
>
> l_dict.remove(PdfName.F);
>
>
> l_dict.put(
>
> PdfName.TYPE,
>
> PdfName.FILESPEC);
>
>
> l_dict.put(
>
> PdfName.F,
>
> l_pdfObject);
>                                                       }
>                                                       if
> (l_dict.contains(PdfName.S)) {
>
> l_dict.put(PdfName.S, PdfName.LAUNCH);
>
> //System.err.println("contains S**"+l_dict.get(PdfName.S).toString());
>                                                       }
>
> //System.err.println("URI " + l_uriVal);
>
> //System.err.println("number of elements in set
> ***"+l_key.toString() +
> "::" + l_value.toString());
>                                                 } // end if
>
>                                           } // end while
>
>                                     } //end if obj !=null
>                               } //end for (int an=0
>                         } //end if (arr !=null
>                         //    System.out.println("*** write
> page ****"+i);
>                         l_page =
> l_writer.getImportedPage(l_reader, l_i);
>                         l_writer.addPage(l_page);
>                   } //end for
>
>                   PRAcroForm l_form = l_reader.getAcroForm();
>                   if (l_form != null)
>                         l_writer.copyAcroForm(l_reader);
>
>                   if (l_master.size() > 0)
>                         l_writer.setOutlines(l_master);
>
>
>
> ----------------------------------------------------------
> Le pr�sent message ainsi que ses �ventuelles pi�ces jointes est
> exclusivement destin� au(x) destinataire(s), personnes physiques ou
> morales, qu'il d�signe.
> Il constitue de ce fait une correspondance � caract�re priv� et peut
> contenir des informations confidentielles.
> Si ce message vous est parvenu par erreur, nous vous
> remercions d'en aviser
> imm�diatement l'exp�diteur par retour de courrier
> �lectronique puis de le
> d�truire, ainsi que ses �ventuelles pi�ces jointes, sans en
> conserver de
> copie.
>
>
> This message, including any attachment, is intended for the use of the
> individual or entity to which it is addressed.
> It is therefore to be considered as a private correspondence which may
> contain confidential information.
> If you are not the intended recipient, please advise the
> sender immediately
> by reply e.mail and delete this message and any attachment
> thereto without
> retaining a copy.
> ----------------------------------------------------------
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
> Project Admins to receive an Apple iPod Mini FREE for your
> judgement on
> who ports your project to Linux PPC the best. Sponsored by IBM.
> Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php
> _______________________________________________
> iText-questions mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
 >



 ----------------------------------------------------------
 Le pr�sent message ainsi que ses �ventuelles pi�ces jointes est
 exclusivement destin� au(x) destinataire(s), personnes physiques ou
 morales, qu'il d�signe.
 Il constitue de ce fait une correspondance � caract�re priv� et peut
 contenir des informations confidentielles.
 Si ce message vous est parvenu par erreur, nous vous remercions d'en
 aviser imm�diatement l'exp�diteur par retour de courrier �lectronique puis
 de le d�truire, ainsi que ses �ventuelles pi�ces jointes, sans en
 conserver de copie.


 This message, including any attachment, is intended for the use of the
 individual or entity to which it is addressed.
 It is therefore to be considered as a private correspondence which may
 contain confidential information.
 If you are not the intended recipient, please advise the sender
 immediately by reply e.mail and delete this message and any attachment
 thereto without retaining a copy.
 ----------------------------------------------------------



-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to