> CFDOCUMENT has been the bane of my existence for years. Check out this simple > dynamic PDF packaging code which should work... > > <CFSET PAGEARRAY = [] /> > <CFLOOP from="1" to="3" index="i"> > <CFDOCUMENT FORMAT="PDF" NAME="PDFPAGE"> > <html><body><div > style="background:url(http://www.houseoffusion.com/_/hof120.gif)"><BR> </div></body></html> > </CFDOCUMENT> > <cfset arrayappend(PAGEARRAY,PDFPAGE) /> > </CFLOOP> > <CFDOCUMENT FORMAT="PDF" NAME="PDFPAGE"> > <html><body><div > style="background:url(http://www.houseoffusion.com/_/hof120.gif)"><BR> </div></body></html> > </CFDOCUMENT> > <cfset arrayappend(PAGEARRAY,PDFPAGE) /> > <CFPDF action="merge" name="FINALPDF"> > <cfloop from="1" to="#arraylen(PAGEARRAY)#" index="i"> > <cfset pointer = PAGEARRAY[i]/> > <cfpdfparam source="pointer"> > </cfloop> > </CFPDF> > <cfcontent type="application/pdf" variable="#tobinary(FINALPDF)#"> > > If you run this (on CF8 or CF9 - not tried 10) you will notice that the image > appears only on the first and last page! Why? > Because CFDocument ignores background images after the first call when in a > loop. I was able to prove this by putting > the call into a CFINCLUDE inside the loop. But then, if you add a > CFDOCUMENTITEM to it, it throws an error: "Routines > cannot be declared more than once". According to Adobe there was a hotfix for > this in CF8, although it did not work for me. > > Anyone know CFDoc well enough to present another solution?
I would expect you can solve this problem by using unique names within your loop: <cfloop from="1" to="3" index="i"> <cfdocument ... name="pdfpage_01_#i#">...</cfdocument> ... <cfdocument ... name="pdfpage_02_#i#">...</cfdocument> ... </cfloop> Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or ons ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351370 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm