Hi,

I'd like to change the url of a pushbutton's submit action - I do this by
changing the corresponding dictionary value. This seems to work in memory,
but when I persist the data to a file (test_changed.pdf) and open this new
file in adobe reader there is still the old/original url present - what do I
have to do in order to "persist" these changes?

ByteArrayOutputStream erzeugtesPDF = new ByteArrayOutputStream();
PdfReader reader = new PdfReader(new FileInputStream("H:/test.pdf"));
PdfStamper stamper = new PdfStamper(reader, erzeugtesPDF, '\0', true);
AcroFields form = stamper.getAcroFields();
AcroFields.Item item = form.getFieldItem("btn_1");
PdfDictionary targetDict =
(PdfDictionary)((PdfDictionary)item.getMerged(0).get(PdfName.A)).get(PdfName.F);
System.out.println("url = " + targetDict.get(PdfName.F)); //prints out the
(original) url
targetDict.put(PdfName.F, new PdfString(
http://iop25.abv.at:58080/FormGenerator/TestServlet2));
stamper.close();
FileOutputStream fos = new
FileOutputStream("H:/work/current/test_changed.pdf");
fos.write(erzeugtesPDF.toByteArray());
fos.flush();
fos.close();



kind regards & many thanks
markus
------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Discover what all the cheering's about.
Get your free trial download today. 
http://p.sf.net/sfu/quest-dev2dev2 
_______________________________________________
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