2

I have a template PDF that has a section that will be laid out like a table. The data will come from a query. So this table will be dynamic, number of rows unknown.

How do I accomplish this using ColdFusion? Is it a combination of creating a template using LiveCycle and creating this section so it is dynamic and then using CFPDF to populate it.

Right now I'm using to populate static fields.

<cfpdfform source="Template.pdf"
   destination="Template2.pdf" action="populate">
   <cfpdfsubform name="form1">
    <cfpdfformparam name="pdf_controlNum" value="123">
    <cfpdfformparam name="pdf_ReportDate" value="05/01/2012">
   </cfpdfsubform>
</cfpdfform>
ale
  • 6,369
  • 7
  • 55
  • 65
Larry
  • 989
  • 4
  • 12
  • 25
  • 1
    I do not use LiveCycle, so hopefully someone else can provide more specific instructions. However, from what I have read you must create a dynamic form in LiveCycle. Then loop through the query in your CF code to generate the cfpdfformparam values [as described here](http://forums.adobe.com/thread/711389?start=0&tstart=0). – Leigh May 24 '12 at 19:36
  • Thanks Leigh, I have looked at the link. the problem I have is the indexing of the field name. does the pdf template know the for each row, the field name will be postfixed with '_#id#' – Larry May 29 '12 at 18:43
  • I am not sure. I got the impression it depends on how the template is structured (and may involve using the `index` attribute too). But that is based on *very* little knowledge of LiveCycle ;-) For the LiveCycle specific portion, you will probably get more timely and accurate answers on the adobe forums. – Leigh May 29 '12 at 19:04
  • I found the solution in following link. The answer is at bottom of thread. http://www.experts-exchange.com/Software/Server_Software/Web_Servers/ColdFusion/Q_26528588.html – Larry May 29 '12 at 20:53
  • the above link does not seem to work correctly. – Larry May 29 '12 at 20:55

2 Answers2

2

I found the solution. It was in this forum:

http://www.experts-exchange.com/Software/Server_Software/Web_Servers/ColdFusion/Q_26528588.html

At bottom of thread was this:

2 key points 1. in cf you need to set overwritedata=”yes” in cfpdfform 2. the pdf needs to be a dynamic pdf.

hope this helps others. I don't have a how to blog but if you know of one just let me know. Very handy indeed.

<cfpdfsubform name="details">    
  <cfpdfsubform name="Table1">
    <cfloop from="1" to="#getClientOrderDetails.recordCount#" index="i">            
      <cfpdfsubform name="Row1" index = "#i#">  
      <cfpdfformparam name="pdfDescription" value="#getClientOrderDetails.ItemDescription[i]#">
        <cfpdfformparam name="pdfItemQuantity" value="#getClientOrderDetails.ItemQuantity[i]#">
        <cfpdfformparam name="pdfItemUnitPrice" value="#getClientOrderDetails.ItemUnitPrice[i]#"> 
      </cfpdfsubform>
    </cfloop> 
   </cfpdfsubform>
 </cfpdfsubform>
Larry
  • 989
  • 4
  • 12
  • 25
  • Glad you solved it! Looks like the main difference is using `index` with the subform. I will tuck that away for future reference. So thanks for posting it. – Leigh May 29 '12 at 21:29
  • also very important, when creating the pdf it needs to be create as a 'dynamic' form. By default, it is created as 'static. That was not obvious. – Larry May 30 '12 at 14:39
0

Did you just want to create a PDF File? If so you also have to call in the style sheet after the cfdocument

<cfdocument 
format="pdf" 
filename = "pdf_file_path\#pdf_controlNum#_#pdf_ReportDate#.pdf"
overwrite = "yes"
marginBottom = ".2"
marginLeft = ".4"
marginRight = ".4"
marginTop = ".2">

<style type="text/css">@import "pdf.css";</style>

QUERY RESULTS TABLES AND CODING HERE ETC

</cfdocument>
Leigh
  • 28,765
  • 10
  • 55
  • 103
Merle_the_Pearl
  • 1,391
  • 3
  • 18
  • 25
  • No, they are trying to populate an existing pdf *form* ie fill in the fields with values. It is a different ball of wax than creating a pdf from scratch. – Leigh May 28 '12 at 05:32