Brook, Please find the code below with inline comments :) This code is working fine... just set the variables of for input & output files according to your need and also the form field population part. This should do it... I just tested the code too and it works fine. I have tested this code with form created in Adobe LiveCycle 8.0
It's actually the "setFormFlattening" property which performs flattening. You need to set it TRUE. I hope this helps. <cfset inputFile = "c:\path to my source form\myform.pdf"> <cfset OutputFile1 = "c:\path to my output file unflattened\out1.pdf"> <cfset OutputFile2 = "c:\path to my output file flattened\out2.pdf"> <cfscript> savedErrorMessage = ""; // cfSearching: All file paths are relative to the current directory fullPathToInputFile = inputFile; fullPathToOutputFile1 = OutputFile1; fullPathToOutputFile2 = OutputFile2; try { // we create a reader for a certain document pdfReader1 = createObject("java", "com.lowagie.text.pdf.PdfReader").init(fullPathToInputFile); //cfSearching: fill in the form fields but do not flatten the form outputStream1 = createObject("java", "java.io.FileOutputStream").init(fullPathToOutputFile1); pdfStamper1 = createObject("java", "com.lowagie.text.pdf.PdfStamper").init(pdfReader1, outputStream1); form1 = pdfStamper1.getAcroFields(); //Populating Form Fields //form1.setField("formfield1", value1); //form1.setField("formfield2", value2); //Flatening the form parameter - keeping it value false will not flaten the form pdfStamper1.setFormFlattening(false); //cfSearching: fill in the form fields AND flatten the form pdfReader2 = createObject("java", "com.lowagie.text.pdf.PdfReader").init(fullPathToInputFile); outputStream2 = createObject("java", "java.io.FileOutputStream").init(fullPathToOutputFile2); pdfStamper2 = createObject("java", "com.lowagie.text.pdf.PdfStamper").init(pdfReader2, outputStream2); form2 = pdfStamper2.getAcroFields(); //Populating form fileds for fomr2 //form2.setField("form2field1", "myValue"); //form2.setField("form2field2", "myValue2"); //Flatening the form parameter - keeping it value true will flaten the form pdfStamper2.setFormFlattening(true); WriteOutput("Finished!"); } catch (java.language.Exception de) { savedErrorMessage = de; } // cfSearching: close the stamper and output stream objects pdfStamper1.close(); outputStream1.close(); pdfStamper2.close(); outputStream2.close(); </cfscript> Regards, Arsalan -------------------------------------------------- From: "Brook Davies" <cft...@logiforms.com> Sent: Wednesday, September 02, 2009 9:52 PM To: "cf-talk" <cf-talk@houseoffusion.com> Subject: RE: CFPDF can not flatten liveCycle Forms - so how do you? > > Come on Arsalan, you say " then let me tell you ... it's not much of a big > deal :) you can use iText java" > > So then, please do tell me, or show me the code that makes this possible? > Brook > > -----Original Message----- > From: Brook Davies [mailto:cft...@logiforms.com] > Sent: September-01-09 1:49 PM > To: cf-talk > Subject: RE: CFPDF can not flatten liveCycle Forms - so how do you? > > > It does not seem to be possible to do flatten XFA forms, even directly via > itext. We've tried.... > > > > -----Original Message----- > From: Arsalan Tariq Keen [mailto:arsalk...@hotmail.com] > Sent: September-01-09 4:28 AM > To: cf-talk > Subject: Re: CFPDF can not flatten liveCycle Forms - so how do you? > > > if you people are concerned about flattening LiveCucle Forms (xml based > pdf > forms) using coldfusion ... then let me tell you ... it's not much of a > big > deal :) you can use iText java library pre-installed with CF (Adobe > CF/Railo/Bluedragon) directly for this purpose :) > > Regards, > Arsalan > > -------------------------------------------------- > From: "Paul Hastings" <p...@sustainablegis.com> > Sent: Tuesday, September 01, 2009 3:58 PM > To: "cf-talk" <cf-talk@houseoffusion.com> > Subject: Re: CFPDF can not flatten liveCycle Forms - so how do you? > >> >> might ask on the iTex list, it will be amusing anyway. >> >> > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:325971 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4