  | 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-10-03 - By Dennis Racine
Back I don't have a problem taking out the setGenerateAppearances(false) but what can i do about keeping the font sizes of the form data the same when the form is populated and/or flattened? They are currently increasing in size from their original setting.
Dennis Racine wrote: > I'm having an issue. When I populate a form with form.setField and > also use the 'setGenerateAppearances(false)' the form opens with the > correct font sizes for data in my form fields. > If I add the form.setFormFlattening(true); then most of the fields > don't even show any data. If I take out the > setGenerateAppearances(false) when flattening, then the data appears, > but a size or 2 bigger than it should be. > What am i doing wrong? Shouldn't it be the same? > > here is my code: > > > <cfscript> > > flatten = #flatRest#; //define path and file name of > the PDF template with form > pdfFile="#inputPDF#"; //define the name of my output file > newFile="#DestFile#"; //create the output file > if (flatten is true){ > fileIO=createObject("java","java.io.FileOutputStream").init(newFile); > //load the template PDF with the iText PDF reader > } else { > fileIO=createObject("java","java.io.ByteArrayOutputStream").init(); > } > reader = > createObject("java","com.lowagie.text.pdf.PdfReader").init(pdfFile); > //load the template into the iText PDF stamper and specify > the output file > pdfStamper = > createObject("java","com.lowagie.text.pdf.PdfStamper").init(reader, > fileIO); //create a form object to reference > pdfForm = pdfStamper.getAcroFields(); > PDFFormField = > createObject("java","com.lowagie.text.pdf.PdfFormField"); > //create object to field attributes > PDFName = createObject("java","com.lowagie.text.pdf.PdfName"); > data.set = 8; > //set the form fields > for (x=1; x lte arraylen(fieldnamelist); x=x+1) > { > writeoutput("<BR>Processing Field: " & fieldnamelist[x]); > curField = pdfForm.getFieldItem(fieldnamelist[x]); > if (isDefined("curField")){ > merged = curField.merged.get(0); > if (PDFName.TX.equals(merged.get(PDFName.FT))){ > n = merged.get(PdfName.FF); > if (isDefined("n") AND BitAnd(n.intValue(), > PdfFormField.FF_MULTILINE) != 0){ > writeOutput("<BR> Found Multiline"); > pdfForm.setExtraMargin(0, 5.2); > } > } > } > pdfForm.setField(fieldnamelist[x], datalist[x]); > pdfForm.setExtraMargin(0, 0); > //pdfForm.setFieldProperty(fieldnamelist[x], "textsize", 8); //no > workie: "The setFieldProperty method was not found." > pdfForm.setGenerateAppearances(false); > > writeOutput("<BR>the Value is: "& PdfFormfield.FF_Multiline); > } > //Flatten > if (flatten is true){ > pdfStamper.setFormFlattening(true); > writeoutput("<BR>Flattening Done..."); > } > pdfStamper.close(); //close pdfStamper (form Filling) > > if (flatten is false){ > // Prepare and display resulting pdf in browser > context = getPageContext(); > context.setFlushOutput(false); > response = context.getResponse().getResponse(); > out = response.getOutputStream(); > response.setContentType("application/pdf"); > response.setContentLength(fileIO.size()); > out.write(fileIO.toByteArray()); > out.flush(); > out.close(); > } > fileIO.close(); // close fileIO > </cfscript> > -- > -- ---- ---- ---- ---- ---- ------ > Racine-Web Design > Dennis Racine > > Tel. 530-470-8751 > Fax (408) 904-4816 > > website: http://www.racine-web.com > webmaster@(protected) > > > Instant Messangers: > Yahoo: dennis_racine > MSN: dennis_rcracing@(protected) (IM Only) > AIM: DRacine33E > ICQ: 967354 > > > -- ---- ---- ---- ---- ---- ------ > > > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- > If this email is spam, report it here: > http://www.OnlyMyEmail.com/ReportSpam > <http://www.onlymyemail.com/view/?action=reportSpam&Id =MzEyMjU6NDA4MDUzNjU0OmRlbm5pc0ByYWNpbmUtd2ViLmNvbQ%3D%3D> > > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > > -- > If this email is spam, report it here: > http://www.onlymyemail.com/view/?action=reportSpam&Id =MzEyMjU6NDA4MDUzNjU0OmRlbm5pc0ByYWNpbmUtd2ViLmNvbQ%3D%3D > > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- > > __ ____ ____ ____ ____ ____ ____ ____ ____ ____ > 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/ > > > > -- > If this email is spam, report it here: > http://www.onlymyemail.com/view/?action=reportSpam&Id =MzEyMjU6NDA4MDUzNjU0OmRlbm5pc0ByYWNpbmUtd2ViLmNvbQ%3D%3D >
-- -- ---- ---- ---- ---- ---- ------ Racine-Web Design Dennis Racine
Tel. 530-470-8751 Fax (408) 904-4816
website: http://www.racine-web.com webmaster@(protected)
Instant Messangers: Yahoo: dennis_racine MSN: dennis_rcracing@(protected) (IM Only) AIM: DRacine33E ICQ: 967354
-- ---- ---- ---- ---- ---- ------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859 (See http://ISO-8859.ora-code.com)-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> <font size="-1">I don't have a problem taking out the </font><font size="-1">setGenerateAppearances(false) but what can i do about keeping the font sizes of the form data the same when the form is populated and/or flattened? They are currently increasing in size from their original setting.<br> <br> </font><br> Dennis Racine wrote: <blockquote cite="mid46F40B8F.6020209@(protected)" type="cite"> <meta content="text/html;charset=ISO-8859 (See http://ISO-8859.ora-code.com)-1" http-equiv="Content-Type"> <font size="-1">I'm having an issue. When I populate a form with form.setField and also use the 'setGenerateAppearances(false)' the form opens with the correct font sizes for data in my form fields.<br> If I add the form.setFormFlattening(true); then most of the fields don't even show any data. If I take out the setGenerateAppearances(false) when flattening, then the data appears, but a size or 2 bigger than it should be. <br> What am i doing wrong? Shouldn't it be the same?<br> <br> here is my code:<br> <br> <br> <cfscript> <br> <br> flatten = #flatRest#; //define path and file name of the PDF template with form <br> pdfFile="#inputPDF#"; //define the name of my output file <br> newFile="#DestFile#"; //create the output file <br> if (flatten is true){ <br> fileIO=createObject("java","java.io.FileOutputStream").init(newFile); //load the template PDF with the iText PDF reader <br> } else { <br> fileIO=createObject("java","java.io.ByteArrayOutputStream").init(); <br> } <br> reader = createObject("java","com.lowagie.text.pdf.PdfReader").init(pdfFile);   ; //load the template into the iText PDF stamper and specify the output file <br> pdfStamper = createObject("java","com.lowagie.text.pdf.PdfStamper").init(reader, fileIO); //create a form object to reference <br> pdfForm = pdfStamper.getAcroFields(); <br> PDFFormField = createObject("java","com.lowagie.text.pdf.PdfFormField"); //create object to field attributes <br> PDFName = createObject("java","com.lowagie.text.pdf.PdfName"); <br> data.set = 8; <br> //set the form fields <br> for (x=1; x lte arraylen(fieldnamelist); x=x+1) <br> { <br> writeoutput("<BR>Processing Field: " & fieldnamelist[x]); <br> curField = pdfForm.getFieldItem(fieldnamelist[x]); <br> if (isDefined("curField")){ <br> merged = curField.merged.get(0); <br> if (PDFName.TX.equals(merged.get(PDFName .FT))){ <br> n = merged.get(PdfName .FF); <br> if (isDefined("n") AND BitAnd(n.intValue(), PdfFormField.FF_MULTILINE) != 0){ <br> writeOutput("<BR> Found Multiline"); <br> pdfForm.setExtraMargin(0, 5.2); <br> } <br> } <br> } <br> pdfForm.setField(fieldnamelist[x], datalist[x]); <br> pdfForm.setExtraMargin(0, 0); <br> //pdfForm.setFieldProperty(fieldnamelist[x], "textsize", 8); //no workie: "The setFieldProperty method was not found." <br> pdfForm.setGenerateAppearances(false); <br> <br> writeOutput("<BR>the Value is: "& PdfFormfield.FF_Multiline); <br> } <br> //Flatten <br> if (flatten is true){ <br> pdfStamper.setFormFlattening(true); <br> writeoutput("<BR>Flattening Done..."); <br> } <br> pdfStamper.close(); //close pdfStamper (form Filling) <br> <br> if (flatten is false){ <br> // Prepare and display resulting pdf in browser <br> context = getPageContext(); <br> context .setFlushOutput(false); <br> response = context.getResponse().getResponse(); <br> out = response.getOutputStream(); <br> response .setContentType("application/pdf"); <br> response .setContentLength(fileIO.size()); <br> out.write(fileIO .toByteArray()); <br> out.flush(); <br> out.close(); <br> } <br> fileIO.close(); // close fileIO <br> </cfscript><br> </font> <pre class="moz-signature" cols="72">-- -- ---- ---- ---- ---- ---- ------ Racine-Web Design Dennis Racine
Tel. 530-470-8751 Fax (408) 904-4816
website: <a class="moz-txt-link-freetext" href="http://www.racine-web.com">http://www.racine-web.com</a> <a class="moz-txt-link-abbreviated" href="mailto:webmaster@(protected)">webmaster@(protected)</a>
Instant Messangers: Yahoo: dennis_racine MSN: <a class="moz-txt-link-abbreviated" href="mailto:dennis_rcracing@(protected)">dennis_rcracing@(protected)</a> (IM Only) AIM: DRacine33E ICQ: 967354
-- ---- ---- ---- ---- ---- ------ </pre> <!-- OnlyMyEmailReportSpamLink --> <br> <hr> <font style="font-size: 11px; font-family: Verdana,Arial,Helvetica,sans-serif; color : rgb(0, 0, 0);">If this email is spam, report it here:<br> <a href="http://www.onlymyemail.com/view/?action=reportSpam&Id =MzEyMjU6NDA4MDUzNjU0OmRlbm5pc0ByYWNpbmUtd2ViLmNvbQ%3D%3D" style="color: rgb(51, 102, 153);">http://www.OnlyMyEmail.com/ReportSpam</a> </font><!-- OnlyMyEmailReportSpamLink --> <pre wrap="">-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ -- ------ This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. <a class="moz-txt-link-freetext" href="http://clk.atdmt.com/MRT/go /vse0120000070mrt/direct/01/">http://clk.atdmt.com/MRT/go/vse0120000070mrt /direct/01/</a>
-- If this email is spam, report it here: <a class="moz-txt-link-freetext" href="http://www.onlymyemail.com/view/?action =reportSpam&Id=MzEyMjU6NDA4MDUzNjU0OmRlbm5pc0ByYWNpbmUtd2ViLmNvbQ%3D%3D">http:/ /www.onlymyemail.com/view/?action=reportSpam&Id =MzEyMjU6NDA4MDUzNjU0OmRlbm5pc0ByYWNpbmUtd2ViLmNvbQ%3D%3D</a> </pre> <pre wrap=""> <hr size="4" width="90%"> __ ____ ____ ____ ____ ____ ____ ____ ____ ____ iText-questions mailing list <a class="moz-txt-link-abbreviated" href="mailto:iText-questions@(protected) .sourceforge.net">iText-questions@(protected)</a> <a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists /listinfo/itext-questions">https://lists.sourceforge.net/lists/listinfo/itext -questions</a> Buy the iText book: <a class="moz-txt-link-freetext" href="http://itext.ugent .be/itext-in-action/">http://itext.ugent.be/itext-in-action/</a>
-- If this email is spam, report it here: <a class="moz-txt-link-freetext" href="http://www.onlymyemail.com/view/?action =reportSpam&Id=MzEyMjU6NDA4MDUzNjU0OmRlbm5pc0ByYWNpbmUtd2ViLmNvbQ%3D%3D">http:/ /www.onlymyemail.com/view/?action=reportSpam&Id =MzEyMjU6NDA4MDUzNjU0OmRlbm5pc0ByYWNpbmUtd2ViLmNvbQ%3D%3D</a> </pre> </blockquote> <br> <pre class="moz-signature" cols="72">-- -- ---- ---- ---- ---- ---- ------ Racine-Web Design Dennis Racine
Tel. 530-470-8751 Fax (408) 904-4816
website: <a class="moz-txt-link-freetext" href="http://www.racine-web.com">http ://www.racine-web.com</a> <a class="moz-txt-link-abbreviated" href="mailto:webmaster@(protected)" >webmaster@(protected)</a>
Instant Messangers: Yahoo: dennis_racine MSN: <a class="moz-txt-link-abbreviated" href="mailto:dennis_rcracing@(protected) .com">dennis_rcracing@(protected)</a> (IM Only) AIM: DRacine33E ICQ: 967354
-- ---- ---- ---- ---- ---- ------ </pre> </body> </html>
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- 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/
|
|
 |