<!--- get the pages --->
<cfset pages = beans.docService.getPagesByVersionID(versionID=versionID)/>
<!--- create array to hold cfdocuments --->
<cfset documents = []/>
<!--- loop pages and create cfdocuments --->
<cfloop query="pages">
<cfdocument name="pdf_name" format="pdf" pageheight="#pages.height#" pagewidth="#pages.width#" pagetype="#pages.doc_page_type_Name#" orientation="pages.document_orientation_type_name#">
<!--- get the page layout --->
<cfset layout[id] = beans.docService.getLayoutByID(pages.layout_id) />
<!--- get xmltransform--->
<cfsilent>
<cfset html[id] = xmltransform(xml,layout[id].xslt) />
</cfsilent>
<!--- set margins --->
<cfdocumentsection
marginbottom="#pages.bottom_margin#"
marginleft="#pages.left_margin#"
marginright="#pages.right_margin#"
margintop="#pages.top_margin#">
<!--- output data --->
<cfoutput>#html[id]#</cfoutput>
</cfdocumentsection>
</cfdocument>
<!--- add binary cfdocument to the --->
<cfset arrayappend(documents,pdf_name) />
</cfloop>
<!--- merge cfdocuments into 1 pdf. this will return some binary --->
<cfpdf action="merge" name="final">
<cfloop from="1" to="#arraylen(documents)#" index="i">
<!--- set pointer for cfpdfparam source, this part took me forever to figure out because the source attribute is looking for a pointer variable. you can't just pass in the binary --->
<cfset pointer = documents[i]/>
<cfpdfparam source="pointer">
</cfloop>
</cfpdf>
<!--- output the pdf --->
<cfcontent type="application/pdf" variable="#tobinary(final)#" reset="No" >
No comments:
Post a Comment