Subject: Re: re placePushButtonField doesn 't work on fields with the same name? 2007-11-02 - By Mark Storer
Back Yep, you found a bug. Have a look at line 2101 through 2120 here: http://itext.svn.sourceforge.net/viewvc/itext/trunk/src/com/lowagie/text/pdf /AcroFields.java?view=markup
You'll see that the function only modifies the first entry in AcroFields.Item.[merged/widget/values]. To handle your case, it would have to enumerate each of those arrays.
Suggestion: Write up a patched version that can replace some or all fields with the same name, and submit it. Something like:
/***DANGER: CODE WRITTEN IN EMAIL EDITOR AHEAD***/ public boolean replacePushbuttonField(String field, PdfFormField button) { return replacePushButtonField( field, button, 0 ); // maintain old behavior } // new version, containing most of the old function public boolean replacePushbuttonField(String field, PdfFormField button, int replaceIndex) { if (replaceIndex == -1) { /*change them all*/ } else { /* change the specified button */ } }
Mark Storer Senior Software Engineer Cardiff.com #include <disclaimer> typedef std::Disclaimer<Cardiff> DisCard;
On 11/2/07, iy <iyeh@(protected)> wrote: > > > I have a PDF with two submit buttons with the same field name. I am using > AcroField replacePushButtonField() to set the submit URL at run time. But > it seems to replace the first submit button only. Is this a bug? how do > I > get around that? I tried renaming one of the submit button to a different > name, but it seems the method renames all fields of the same name, so that > doesn't help. The two buttons are on the same page. > -- > View this message in context: http://www.nabble.com/replaceP > ushButtonField-doesn%27t-work-on-fields-with-the-same-name-- > tf4737381.html#a13547490 > Sent from the iText - General mailing list archive at Nabble.com. > > > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- > 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/ >
-- --Mark Storer Professional Geek
<font style="font-family: courier new,monospace;" size="2">Yep, you found a bug . Have a look at line 2101 through 2120 here: <a href="http://itext .svn.sourceforge.net/viewvc/itext/trunk/src/com/lowagie/text/pdf/AcroFields.java ?view=markup"> http://itext.svn.sourceforge.net/viewvc/itext/trunk/src/com/lowagie/text/pdf /AcroFields.java?view=markup</a><br><br>You'll see that the function only modifies the first entry in AcroFields.Item.[merged/widget/values]. To handle your case, it would have to enumerate each of those arrays. <br><br>Suggestion: Write up a patched version that can replace some or all fields with the same name, and submit it. Something like:<br><br>/** *DANGER: CODE WRITTEN IN EMAIL EDITOR AHEAD***/<br></font><font size="2"><span style="font-family: courier new,monospace;" class="kwa"> public</span><span style="font-family: courier new,monospace;"> </span><span style="font-family: courier new,monospace;" class="kwb">boolean</span><span style="font-family: courier new,monospace;"> </span><span style="font-family: courier new,monospace;" class="kwd"> replacePushbuttonField</span><span style="font-family: courier new,monospace;" class="sym">(</span><span style="font-family: courier new,monospace;" class= "kwc">String</span><span style="font-family: courier new,monospace;"> field</span><span style="font-family: courier new,monospace;" class="sym">,< /span><span style="font-family: courier new,monospace;"> PdfFormField button< /span><span style="font-family: courier new,monospace;" class="sym"> ) {<br></span><span style="font-family: courier new,monospace;"> return replacePushButtonField( field, button, 0 ); // maintain old behavior</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font -family: courier new,monospace;">// new version, containing most of the old function</span><br style="font-family: courier new,monospace;"><span style= "font-family: courier new,monospace;" class="kwa"> public</span><span style="font-family: courier new,monospace;"> </span><span style="font-family: courier new,monospace;" class="kwb">boolean</span><span style="font-family: courier new,monospace;"> </span><span style="font-family: courier new,monospace;" class="kwd"> replacePushbuttonField</span><span style="font-family: courier new,monospace;" class="sym">(</span><span style="font-family: courier new,monospace;" class= "kwc">String</span><span style="font-family: courier new,monospace;"> field</span><span style="font-family: courier new,monospace;" class="sym">,< /span><span style="font-family: courier new,monospace;"> PdfFormField button, int replaceIndex) {</span><br style="font-family: courier new,monospace;"> <span style="font-family: courier new,monospace;"> if (replaceIndex == -1) {</span><br style="font-family: courier new,monospace;"><span style="font -family: courier new,monospace;"> /*change them all*/</span><br style="font -family: courier new,monospace;"> <span style="font-family: courier new,monospace;"> } else {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> /* change the specified button */</span><br style="font -family: courier new,monospace;"> <span style="font-family: courier new,monospace;"> }</span><br style="font -family: courier new,monospace;"><span style="font-family: courier new,monospace ;" class="sym"></span><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"></font><pre style="font -family: courier new,monospace;"><font size="2"> Mark Storer <br> Senior Software Engineer <br> <a href="http://Cardiff.com">Cardiff.com</a> <br>#include <disclaimer> <br>typedef std::Disclaimer<Cardiff> DisCard; <br></font></pre><font style="font-family: courier new,monospace;" size="2"><br></font><div style="font-family: courier new,monospace;"><font size ="2"> <span class="gmail_quote">On 11/2/07, <b class="gmail_sendername">iy</b> <<a href="mailto:iyeh@(protected)">iyeh@(protected)</a>> wrote:</span></font> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204) ; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <font size="2"><br>I have a PDF with two submit buttons with the same field name. I am using<br>AcroField replacePushButtonField() to set the submit URL at run time. But<br>it seems to replace the first submit button only. Is this a bug? how do I <br>get around that? I tried renaming one of the submit button to a different<br>name, but it seems the method renames all fields of the same name, so that<br>doesn't help. The two buttons are on the same page. <br>-- <br>View this message in context: <a href="http://www.nabble.com/replaceP">http ://www.nabble.com/replaceP</a></font><font size="2">ushButtonField-doesn%27t -work</font><font size="2">-on-fields-with-the-same-name-</font><font size="2"> -tf4737381.html#a13547490<br>Sent from the iText - General mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br><br><br>-- ---- ---- ---- --- -- ------</font><font size="2">-- ---- ---- ---- ---- ---- --</font> <font size="2">-- ---- -----<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 href="http://get.splunk.com/">http://get.splunk.com/</a><br>__ ____ ____ ___ __ ____ ______</font><font size="2">__ ____ ____ ____<br>iText-questions mailing list<br><a href="mailto:iText-questions@(protected)">iText-questions@(protected) .sourcefo </a></font><font size="2"><a href="http://rge.net">rge.net</a><br><a href= "https://lists.sourceforge.net">https://lists.sourceforge.net</a></font><font size="2">/lists/listinfo/itext-question</font><font size="2">s<br>Buy the iText book: <a href="http://itext.ugent.be/itext-in">http://itext.ugent.be/itext-in</a>< /font><font size="2">-action/<br></font></blockquote></div><font style="font -family: courier new,monospace;" size="2"><br><br clear="all"><br>-- <br>--Mark Storer<br>Professional Geek </font>
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- 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/
|
|