  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | -none- | -none- 2007-08-21 - By Robert Cearley
Back In adobe professional 8.0, there is a setting called: Enable Usage rights in adobe reader. This setting allows you to create a pdf document so a person can enter data into the pdf and save it.
If I populate the pdf document using the setnodetext method below, the populate method works; however, the document seems to lose the ability for a user to type in data into the document and resave it.
Here's what I'm trying to do. The code below will populate some basic fields on a pdf. The pdf will be sent to a user that will add additional text in the pdf. He will save the pdf with the data he entered; however, the save option is lost. Any ideas?
Sample code:
PdfReader reader = new PdfReader(sourcefilename);
stamp = new PdfStamper(reader, File.Create(base.NewFileName));
AcroFields form = stamp.AcroFields;
XfaForm xfaForm = form.Xfa;
XmlNode internalIdNode;
internalIdNode = xfaForm.FindDatasetsNode("firstname");
xfaForm.SetNodeText(internalIdNode, "john doe");
stamp.FormFlattening = false; stamp.Close();
Thanks...
<span style="FONT-SIZE: 5pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><span style="mso-spacerun: yes"> <div class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" ><span style="FONT-SIZE: 5pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><font size="2"></font></span> </div> <div class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" ><span style="FONT-SIZE: 5pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><font size="2">In adobe professional 8.0, there is a setting called: Enable Usage rights in adobe reader. </font></span><span style="FONT-SIZE: 5pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><font size="2">This setting allows you to create a pdf document so a person can enter data into the pdf and save it. </font> </span></div> <div class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" ><span style="FONT-SIZE: 5pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><font size="2"></font></span> </div> <div class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" ><span style="FONT-SIZE: 5pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><font size="2">If I populate the pdf document using the setnodetext method below, the populate method works; however, the document seems to lose the ability for a user to type in data into the document and resave it. </font></span></div> <div class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" ><span style="FONT-SIZE: 5pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><font size="2"></font></span> </div> <div class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" ><span style="FONT-SIZE: 5pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><font size="2">Here's what I'm trying to do. The code below will populate some basic fields on a pdf. The pdf will be sent to a user that will add additional text in the pdf. He will save the pdf with the data he entered; however, the save option is lost. Any ideas? </font></span></div> <div class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" ><span style="FONT-SIZE: 5pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><font size="2"></font></span> </div> <div class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" ><span style="FONT-SIZE: 5pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><font size="2"></font></span> </div> <div class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" ><span style="FONT-SIZE: 5pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><font size="2">Sample code:</font></span><span style="FONT-SIZE: 5pt; FONT -FAMILY: 'Courier New'; mso-no-proof: yes"> </span></div> <div class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" ><span style="FONT-SIZE: 5pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"></span> </div> <div class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" ><span style="FONT-SIZE: 5pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"></span> </div> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"> <font size="2"><span style="COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">PdfReader</span><span style="FONT-FAMILY: 'Courier New& #39;; mso-no-proof: yes"> reader = <span style="COLOR: blue">new</span> <span style="COLOR: #2b91af" >PdfReader</span>(sourcefilename);</span></font></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"> <span style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><font size= "2">stamp = <span style="COLOR: blue">new</span> <span style="COLOR: #2b91af"> PdfStamper</span>(reader, <span style="COLOR: #2b91af">File</span>.Create(<span style="COLOR: blue">base</span>.NewFileName));</font></span></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"> <font size="2"><span style="COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">AcroFields</span><span style="FONT-FAMILY: 'Courier New& #39;; mso-no-proof: yes"> form = stamp.AcroFields;</span></font></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"> <font size="2"><span style="COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">XfaForm</span><span style="FONT-FAMILY: 'Courier New' ;; mso-no-proof: yes"> xfaForm = form.Xfa;</span></font></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"> <font size="2"><span style="COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">XmlNode</span><span style="FONT-FAMILY: 'Courier New' ;; mso-no-proof: yes"> internalIdNode;</span></font></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"> <span style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><font size= "2"> </font></span></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"> <span style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><font size= "2">internalIdNode = xfaForm.FindDatasetsNode("firstname");</font> </span></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"> <span style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><font size= "2">xfaForm.SetNodeText(internalIdNode, "john doe");<span style="mso-spacerun: yes"> </span><span style="mso-spacerun: yes"> </span></font></span ></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"> <span style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><font size= "2"> </font></span></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"> <span style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><font size= "2">stamp.FormFlattening = <span style="COLOR: blue">false</span> ;<span style="mso-spacerun: yes"> </span><span style="mso -spacerun: yes"> </span></font></span></p> <div class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" ><span style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><font size= "2">stamp.Close();<span style="mso-spacerun: yes"> </span></font></span></div> <div class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" ><span style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><font size= "2"><span style="mso-spacerun: yes"></span></font></span> </div>
<div class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" ><span style="FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><font size= "2"><span style="mso-spacerun: yes">Thanks...</span></font></span> </div></span></span>
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ __ ____ ____ ____ ____ ____ ____ ____ ____ ____ iText-questions mailing list iText-questions@(protected) https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/
|
|
 |