  | 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 Hi Leonard,
Thanks for your reply. Is there any other way to save the document so the settings are not lost - a possible hack or via XFA? Here's the scenario. We have a software system that has multiple pdf templates that users can select to merge with their data. They do a merge and then download the merged document to enter additional data on their side. Once they are done, they mail the pdf document back to the server, and the server imports the data they changed back into the database.
I was able to narrow it down to the following, which causes the same problem.
string sourcefilename = @"c:\temp\saveenabled.pdf"; PdfReader reader = new PdfReader(sourcefilename); PdfStamper stamp = new PdfStamper(reader, File.Create( @"c:\temp\saveenabled1.pdf")); stamp.Close(); When you open the document it says: This document contained certain rights to enable special features in adobe reader. this document has been changed since it was created and these rights are no longer valid. please contact the author for the original version of this document.
On 8/21/07, Leonard Rosenthol <leonardr@(protected)> wrote: > > You need to do your form filling BEFORE the PDF is "Reader Enabled". > > Leonard > > On Aug 21, 2007, at 3:43 PM, Robert Cearley wrote: > > > 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... > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- > 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/ > > > > > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- > 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/ > >
<div><font size="2"> <p>Hi Leonard,<br><br>Thanks for your reply. Is there any other way to save the document so the settings are not lost - a possible hack or via XFA? Here's the scenario. We have a software system that has multiple pdf templates that users can select to merge with their data. They do a merge and then download the merged document to enter additional  ;data on their side. Once they are done, they mail the pdf document back to the server, and the server imports the data they changed back into the database. </p></font> <p><font color="#0000ff" size="2">I was able to narrow it down to the following , which causes the same problem. </font></p> <p><font color="#0000ff" size="2">string</font><font size="2"> sourcefilename = </font><font color="#a31515" size="2">@"c:\temp\saveenabled.pdf"< /font><font size="2">;<br></font><font color="#2b91af" size="2">PdfReader </font><font size="2"> reader = </font><font color="#0000ff" size="2">new</font ><font size="2"> </font><font color="#2b91af" size="2">PdfReader</font><font size="2">(sourcefilename);<br></font><font color="#2b91af" size="2"> PdfStamper</font><font size="2"> stamp = </font><font color="#0000ff" size="2" >new</font><font size="2"> </font><font color="#2b91af" size="2">PdfStamper< /font><font size="2">(reader, </font><font color="#2b91af" size="2"> File</font><font size="2">.Create(</font><font color="#a31515" size="2">@" ;c:\temp\saveenabled1.pdf"</font><font size="2">));<br></font><font size="2 ">stamp.Close();</font></p></div> <div>When you open the document it says: This document contained certain rights to enable special features in adobe reader. this document has been changed since it was created and these rights are no longer valid. please contact the author for the original version of this document. </div> <div><br><br> </div> <div><span class="gmail_quote">On 8/21/07, <b class="gmail_sendername">Leonard Rosenthol</b> <<a href="mailto:leonardr@(protected)">leonardr@(protected)< /a>> wrote:</span> <blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0 .8ex; BORDER-LEFT: #ccc 1px solid"> <div style="WORD-WRAP: break-word">You need to do your form filling BEFORE the PDF is "Reader Enabled". <div><br> </div> <div>Leonard</div> <div><br> <div> <div><span class="e" id="q_1148a0882dee4204_1"> <div>On Aug 21, 2007, at 3:43 PM, Robert Cearley wrote:</div><br></span></div> <blockquote type="cite"> <div><span class="e" id="q_1148a0882dee4204_3"><span style="FONT-SIZE: 5pt"> <span> <div style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 5pt"><font size="2">< /font></span> </div> <div style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 5pt"><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 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 style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 5pt"><font size="2">< /font></span> </div> <div style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 5pt"><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 style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 5pt"><font size="2">< /font></span> </div> <div style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 5pt"><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 style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 5pt"><font size="2">< /font></span> </div> <div style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 5pt"><font size="2">< /font></span> </div> <div style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 5pt"><font size="2" >Sample code:</font></span><span style="FONT-SIZE: 5pt"> </span></div> <div style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 5pt"></span> < /div> <div style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 5pt"></span> < /div> <div style="MARGIN: 0in 0in 0pt"><font size="2"><span style="COLOR: #2b91af" >PdfReader</span><span> reader = <span style="COLOR: blue">new</span> <span style="COLOR: #2b91af">PdfReader</span>(sourcefilename);</span></font> </div> <div style="MARGIN: 0in 0in 0pt"><span><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></div> <div style="MARGIN: 0in 0in 0pt"><font size="2"><span style="COLOR: #2b91af" >AcroFields</span><span> form = stamp.AcroFields;</span></font></div> <div style="MARGIN: 0in 0in 0pt"><font size="2"><span style="COLOR: #2b91af" >XfaForm</span><span> xfaForm = form.Xfa;</span></font></div> <div style="MARGIN: 0in 0in 0pt"><font size="2"><span style="COLOR: #2b91af" >XmlNode</span><span> internalIdNode;</span></font></div> <p style="MARGIN: 0in 0in 0pt"><span><font size="2"> </font></span></p> <div style="MARGIN: 0in 0in 0pt"><span><font size="2">internalIdNode = xfaForm .FindDatasetsNode("firstname");</font> </span></div> <div style="MARGIN: 0in 0in 0pt"><span><font size="2">xfaForm.SetNodeText (internalIdNode, "john doe");<span> < /span><span> < /span></font></span></div> <p style="MARGIN: 0in 0in 0pt"><span><font size="2"> </font></span></p> <div style="MARGIN: 0in 0in 0pt"><span><font size="2">stamp.FormFlattening = <span style="COLOR: blue">false</span> ;<span> </span><span> </span></font></span></div> <div style="MARGIN: 0in 0in 0pt"><span><font size="2">stamp.Close();<span>  ; </span></font></span></div> <div style="MARGIN: 0in 0in 0pt"><span><font size="2"><span></span></font>< /span> </div> <div style="MARGIN: 0in 0in 0pt"><span><font size="2"><span>Thanks...</span>< /font></span> </div></span></span></span></div> <div style="MARGIN: 0px">-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ -- ---- ---- ------</div> <div style="MARGIN: 0px">This SF.net email is sponsored by: Splunk Inc.</div> <div style="MARGIN: 0px">Still grepping through log files to find problems? <span> </span>Stop.</div> <div style="MARGIN: 0px">Now Search log events and configuration files using AJAX and a browser.</div> <div style="MARGIN: 0px">Download your FREE copy of Splunk now >><span> </span><a onclick="return top.js.OpenExtLink(window,event,this)" href= "http://get.splunk.com/__ ____ ____ ____ ____ ____ ____ ____ ____ ____" target=" _blank"> http://get.splunk.com/__ ____ ____ ____ ____ ____ ____ ____ ____ ____</a></div> <div style="MARGIN: 0px">iText-questions mailing list</div> <div style="MARGIN: 0px"><a onclick="return top.js.OpenExtLink(window,event ,this)" href="mailto:iText-questions@(protected)" target="_blank" >iText-questions@(protected)</a></div> <div style="MARGIN: 0px"><a onclick="return top.js.OpenExtLink(window,event ,this)" href="https://lists.sourceforge.net/lists/listinfo/itext-questions" target="_blank">https://lists.sourceforge.net/lists/listinfo/itext-questions </a></div> <div style="MARGIN: 0px">Buy the iText book: <a onclick="return top.js .OpenExtLink(window,event,this)" href="http://itext.ugent.be/itext-in-action/" target="_blank">http://itext.ugent.be/itext-in-action/</a></div></blockquote> </div><br> </div></div><br>-- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- ---- ---- ---- ---- ---<br>This SF.net email is sponsored by: Splunk Inc.<br >Still grepping through log files to find problems? Stop.<br>Now Search log events and configuration files using AJAX and a browser. <br>Download your FREE copy of Splunk now >> <a onclick="return top .js.OpenExtLink(window,event,this)" href="http://get.splunk.com/" target="_blank ">http://get.splunk.com/</a><br>__ ____ ____ ____ ____ ____ ____ ____ ____ ____ <br>iText-questions mailing list<br><a onclick="return top.js.OpenExtLink (window,event,this)" href="mailto:iText-questions@(protected)">iText -questions@(protected)</a><br><a onclick="return top.js.OpenExtLink (window,event,this)" href="https://lists.sourceforge.net/lists/listinfo/itext -questions" target="_blank"> https://lists.sourceforge.net/lists/listinfo/itext-questions</a><br>Buy the iText book: <a onclick="return top.js.OpenExtLink(window,event,this)" href= "http://itext.ugent.be/itext-in-action/" target="_blank">http://itext.ugent.be /itext-in-action/ </a><br><br></blockquote></div><br>
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- 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/
|
|
 |