Skip to main content
July 11, 2009
Answered

How do I create a Dynamic PDF in ColdFusion

  • July 11, 2009
  • 4 replies
  • 7091 views

I am using ColdFusion CS4 and I need to create a dynamic PDF certificate for the user when they finish a short test.


Their name is in a session var and should dynamically enter in to the Name field of the certificate as well as the date.
The user can print The PDF certificate, which must be protected to Allow Print only.


I have a PDF created in Adobe Lifecycle Designer. This contains all the data and a text field Name and Data that needs the dynamic input from ColdFusion.

<cfpdfform action="populate" source="certificate.pdf">
      <cfpdfsubform name="form1">
            <cfpdfsubform name="page1">
                  <cfpdfformparam name="employeeName" value="John Hollings" />
                  <cfpdfformparam name="date" value="#dateformat(now(), 'dd mmmm, yyyy')#" />
                  <cfpdfformparam name="submitURL" value="#CGI.SCRIPT_NAME#" />
                  </cfpdfsubform>
      </cfpdfsubform>
</cfpdfform>

Thsi work but the PDF textFields are open to edit, I need to lock down the PDF so only printing can operate...
No Copy of data
No Saving the file (if possible)
Only print and close

    This topic has been closed for replies.
    Correct answer Leonard_B

    Greetings act332,

    I do this sort of stuff all the time for fire training sessions I do.

    Instead of using <cfpdfform>, try using the <cfdocument> tag

    and designing your certificate content within ColdFusion. This

    will allow for setting permissions for what the end user can do

    with the doc (i.e. print only). You will need to use inline CSS

    for font styling and full path information for any images you

    want included. Use <cfoutput></cfoutput> tags to include your

    dynamic information where you desire it to appear.

    I have set mine up to print on 8.5 x 11.0 certificate stock,which

    can be purchased at any office supply store. Just change the

    orientation of the <cfdocument> tag for either landscape or

    portrait style certificates.

    Leonard

    4 replies

    August 3, 2009

    Thanks to all, I used Leonard'a answer and I now have a PDF certificate thanks again.

    John (Ex Fire Service)

    Leonard_BCorrect answer
    Inspiring
    August 3, 2009

    Greetings act332,

    I do this sort of stuff all the time for fire training sessions I do.

    Instead of using <cfpdfform>, try using the <cfdocument> tag

    and designing your certificate content within ColdFusion. This

    will allow for setting permissions for what the end user can do

    with the doc (i.e. print only). You will need to use inline CSS

    for font styling and full path information for any images you

    want included. Use <cfoutput></cfoutput> tags to include your

    dynamic information where you desire it to appear.

    I have set mine up to print on 8.5 x 11.0 certificate stock,which

    can be purchased at any office supply store. Just change the

    orientation of the <cfdocument> tag for either landscape or

    portrait style certificates.

    Leonard

    Known Participant
    August 3, 2009

    Thanks Leonard. When I tried that solution, the resulting file size was

    huge. I have a border image, but it is only a few 100K, but I was getting

    PDF files of like 5MB. Maybe I was doing something wrong in the output?

    -


    Original Message

    Inspiring
    August 3, 2009

    What exactly is the code doing? Did you just decide to ditch the LiveCycle form altogether and use cfdocument?

    Known Participant
    July 23, 2009

    Did you find a solution to this?  I am doing pretty much the exact same thing and have the same problem.

    Thanks!

    Inspiring
    July 23, 2009

    Which problem?  You can set permissions using cfpdf's "permissions" attribute.  As far as flattening a LiveCycle form with ColdFusion, the answer is you cannot, AFAIK.

    Known Participant
    July 23, 2009

    The problem of the form field being able to be edited after the PDF is made.  I read another post that said to just create the PDF form right in Acrobat (which is waht I thought I did, but Acrobat launches LC automatically), then you can flatten it using cfpdf and thta solves the problem.  So, I will try that.

    Inspiring
    July 11, 2009

    You can set permission using cfpdf's "permissions" attribute  or ddx

    http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_p-q_02.html

    act332 wrote:

    Thsi work but the PDF textFields are open to edit

    IIRC, you will have to convert to an Acrobat form if you want to "flatten" the fields using cfpdf or ddx.  I believe cfpdf/ddx do not permit the flattening of LiveCycle forms, only Acrobat forms.

    July 12, 2009

    Thanks for your reply,

    I think I am over my head here, If I make a form in Adobe Pro9 it opens Lifecycle and I am back there.

    I am trying to allow a user to print a document (certificate) with their name and date dynamically inserted, this document must be locked so the user can not change it in anyway - only print it.

    May be I am looking at this the wrong way???

    But thanks again for you help.

    Inspiring
    July 12, 2009

    act332 wrote:

    If I make a form in Adobe Pro9 it opens Lifecycle and I am back there.


    Unfortunately, I am not using Acrobat 9/LiveCycle. So I cannot really provide any specifics there. For usage questions, you might try asking on the Acrobat/LiveCycle forums.   But from CF's perspective, the key is the form's _format_.  Acrobat (AcroForms) and LiveCycle forms are two totally different formats internally.  (Like MS Office 2007 files versus MS Office 2003 files). To flatten a form from CF, it must be an AcroForm:

    http://www.planetpdf.com/article.asp?ContentID=adobe_live_cycle_designer_and_acrobat_pdf_forms_under_the_hood&page=1

    act332 wrote:

    I am trying to allow a user to print a document (certificate) with their name and date dynamically inserted, this document

    Well as I mentioned, you can use cfpdf or ddx to set whatever permissions you need. The default is "All" (ie all actions are allowed) but you can restrict the permissions by passing in a list of which permissions _should_ be allowed. Anything not included in the list will be restricted.

    <cfpdf permissions="None" ...>   OR
    <cfpdf permissions="AllowPrinting" ...>  OR
    <cfpdf permissions="AllowPrinting,AllowCopy" ...>  OR
    ...