Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

Re: [iText-questions] form field fontsize changing with
 using  setFormFlattening(true);

Dennis Racine

2007-10-03


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@racine-web.com


Instant Messangers:
Yahoo: dennis_racine
MSN: dennis_rcracing@hotmail.com (IM Only)
AIM: DRacine33E
ICQ: 967354


----------------------------------
  


If this email is spam, report it here:
http://www.OnlyMyEmail.com/ReportSpam
-------------------------------------------------------------------------
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@lists.sourceforge.net 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@racine-web.com


Instant Messangers:
Yahoo: dennis_racine
MSN: dennis_rcracing@hotmail.com (IM Only)
AIM: DRacine33E
ICQ: 967354


----------------------------------

Attachment: dennis.vcf
-------------------------------------------------------------------------
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/
©2008 junlu.com - Jax Systems, LLC, U.S.A.