在Coldfusion中为一个目录创建多个PDF
我正在尝试创建多个PDF并将它们保存到一个目录中。我有一个基于Appid的查询。对于每个appid,我需要创建一个pdf并存储在该位置。我能够为一个appid创建pdf。当我尝试为多个appid创建pdf时,数据将添加到当前pdf中。下面是我的代码。请告诉我这里出了什么问题在Coldfusion中为一个目录创建多个PDF,pdf,coldfusion,Pdf,Coldfusion,我正在尝试创建多个PDF并将它们保存到一个目录中。我有一个基于Appid的查询。对于每个appid,我需要创建一个pdf并存储在该位置。我能够为一个appid创建pdf。当我尝试为多个appid创建pdf时,数据将添加到当前pdf中。下面是我的代码。请告诉我这里出了什么问题 <cfquery name="getdetails" datasource="#CSTTDB#" username="#CSTTUSR#" password="#CSTTPWD#"> select a.motsi
<cfquery name="getdetails" datasource="#CSTTDB#" username="#CSTTUSR#" password="#CSTTPWD#">
select a.motsid,B.APP,B.ITCONTACT,B.STD,B.ED,B.DIRECTOR,a.tool,a.upddate,a.EAQUESTION from bnsit.TBLEAMGMT a,scott.tblaccessmgmt b
where A.MOTSID = b.motsid
and a.motsid = '16'
and a.recid = '28'
and a.EAQUESTION = 'Yes'
</cfquery>
<cfif getdetails.recordcount gt 0>
<cfloop query="getdetails">
<cfdocument
format="pdf"
srcfile="\\wiwauk4colddw11.itservices.sbc.com\ITUPCOMP\pdf\"
filename="#getdetails.motsid#_#dateformat(upddate,"mmddyy")#_eareport.pdf"
overwrite="yes">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Emergency Access BNSIT - #getdetails.motsid#</title>
</head>
<style type="text/css" media="print">
td{
width=50%;
}
.tpx td{
border: solid 1px black;
}
</style>
<body>
<img src="email_header_plain.jpg" align="center" border= "0" alt="Header">
<p align="center">
<font size="+2" color="navy"> <strong>EMERGENCY ACCESS BNSIT</strong></font>
</p>
<br>
<cfoutput>
<cfset timenow = dateformat(now(),'mm/dd/yyyy')>
<TABLE id="mytable" align="center" class="tpx" bgcolor="azure" border="1" width="80%">
<tr>
<tr>
<th align="left"><strong>MOTSID:</strong></th>
<th align="left">#motsid#</th>
</tr>
<tr>
<th align="left"><strong>Application Name:</strong></th>
<th align="left">#app#</th>
</tr>
<tr>
<th align="left"><strong>IT Contact:</strong></th>
<th align="left">#itcontact#</th>
</tr>
<tr>
<th align="left"><strong>STD:</strong></th>
<th align="left">#STD#</th>
</tr>
<tr>
<th align="left"><strong>Director:</strong></th>
<th align="left">#director#</th>
</tr>
<tr>
<th align="left"><strong>ED:</strong></th>
<th align="left">#ED#</th>
</tr>
<tr>
<th align="left"><strong>Access Provisioning Tool:</strong></th>
<th align="left"> </th>
</tr>
<tr>
<th align="left"><strong>Emergency Access Tool:</strong></th>
<th align="left">#tool#</th>
</tr>
<tr>
<th align="left"><strong>Confirmation Received Date:</strong></th>
<th align="left">#dateformat(upddate,"mm/dd/yyyy")#</th>
</tr>
</table>
</cfoutput>
</body>
</html>
</cfdocument>
</cfloop>
<cffile action="COPY" source="\\wiwauk4colddw11.itservices.sbc.com\ITUPCOMP\pdf\#getdetails.motsid#_#dateformat(upddate,"mmddyy")#_eareport.pdf" destination="\\135.16.235.36\devcompliance\pdfreports\">
</cfif>
编辑:我已经更新了上面的代码,我正在尝试将创建的pdf文件从一个位置复制到另一个服务器。正在使用给定的命名约定在源文件夹中创建pdf文件
但我得到下面的错误在CFF文件副本。有什么想法吗
此代码
<cfdocument
format="pdf"
srcfile="\\wiwauk4colddw11.itservices.sbc.com\ITUPCOMP\pdf\"
filename="testpdf.pdf"
overwrite="yes">
这将创建一个新的PDF文件,其名称对于每个motsid都是唯一的。否则,您将继续重新创建一个名为testpdf.pdf的文件,该文件最终将包含查询中最后一条记录的内容。非常感谢!最初,我像您所说的那样将cfloop移出cfdocument,但没有移动end标记!!!!现在,我做到了,它的工作再次感谢!循环中有cfdocument元素,我只能在页面中看到一张pdf发票,而我应该看到两张。如果我将cfdocument元素移到循环之外,那么我会在一个pdf中看到我的两张发票,这不是我所需要的。
<cfloop query="getdetails">
<cfdocument
format="pdf"
srcfile="\\wiwauk4colddw11.itservices.sbc.com\ITUPCOMP\pdf\"
filename="testpdf_#getdetails.motsid#.pdf"
overwrite="yes">
<!--- HTML content --->
</cfdocument>
</cfloop>