EasyCFM.COM ColdFusion Forums / Coding Help! / Help with another tutorial: Form to PDF

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Help with another tutorial: Form to PDF

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

10-16-2002 @ 7:10 AM
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 1
Joined: Oct 2002

Here's something that I ran across that doesn't seem to work (at least I couldn't make it work with MX).

I don't have the author attribution easily available, but I'm sure I could find it if anyone is interested.

In any case, I'd be interested if someone knows how to make something like this work (a situation where you can use form inputs to populate PDF form fields and present the pdf to the end user or mail it or whatever).

I'll list the entire set of instructions below.

Thanks in advance.


PDF Form Fields  How To
This example was done with Adobe 5 and Word 2K

1.     Create the .doc or .dot as you require.
2.     Save it as a .pdf using Adobe
3.     Open the pdf with Adobe
4.     Add the form fields.  This is done by clicking on the form tool and placing the field where you want it.

In my example the grid is turned on (CTRL U) or by clicking on View|Grid
The grid settings are adjusted by clicking on Edit|General|Layout Grid.  In this case, the width and height between lines is .25” with two subdivisions.

5.     Right-click on the field, then on “Properties”.  Next click on “Options”.
6.     In the example, the first field is called “today” and the default is called #todayDate#.  This will be a variable name a little later.  The “Type” is text. This is the default.
7.     The second field in the example is done the same way.
8.     Save the pdf.
9.     Next, click on “File|Export|Form Data” and save the exported form (This is the .fdf) to the same directory as the pdf.
10.     Now, start ColdFusion studio and open the fdf this way:  Click on File|Open|All Files.  You will see a warning that this is an unrecognized text file.  Click on “Open”, anyway.
11.       Place a <CFOUTPUT> tag right before the first % sign in the fdf and a </CFOUTPUT> immediately after the EOF at the end of the fdf.  The example shows you where.  Spaces before or after the tags will generate errors.
12.     In the area where you see  “/F (sampledoc.pdf)/ID” (without the quotes) add an URL path before the filename, such as “http://servername/directory structure/filename” (without the quotes). See the example.  Where you see servername above, you can use localhost or an IP address.
13.     Save the file.
14.     Open a new CF template and add the code per the example.  Save it.
15.       You sre ready to go.

NOTES:   1.  Adobe will not preserve your source document margins.
2.     The text in the Adobe document will not be in exactly the place as the source document.  To get
     Adobe to put things where you want them, you have to “play” with the source document.
3.  You CANNOT open the fdf with Adobe. You will get an error.  Open it with CF Studio.

The FDF looks like this:

1 0 obj
/FDF << /Fields [ << /V (#fieldcontent#)/T (fieldcontent)>> << /V (#todayDate#)/T (today)>>
/F (http://master/dqa/adobe/sampledoc.pdf)/ID [ <c2331da405f412d95820b8849ee5fb59><0f5bb617ffcfb2e18a1dd497cd3c2b18>
] >>
/Root 1 0 R


The CF template looks like this:

<!---set date --->
<cfset todayDate=#day(now())#&" "&#MonthAsString(month(now()))#&",  "&#year(now())#>

<!---simulate a query variable--->
<cfset simulatedcontent="This could be a query result">
<!--- if a query, it could be <cfset simulatedcontent = "#queryname.fieldname#"> --->

<!---this comes next--->
<cfsetting enablecfoutputonly="yes">

<!---add variables--->
<cfset variables.todayDate="#todayDate#">
<cfset variables.fieldcontent="#simulatedcontent#">

<!---Fire it up--->
<cfheader name="content-disposition" value="inline;filename=sampledoc.fdf">
<cfcontent type="application/vnd.fdf">
<cfsetting enablecfoutputonly="no">
<cfinclude template="sampledoc.fdf">

12-12-2002 @ 3:58 PM
Send P.M.
My Gravatar!
Powered by Gravatar
Posts: 4542
Joined: Jan 2002

Still need help with this?

Pablo Varando

Website Designed and Developed by Pablo Varando.