我正在尝试将我的CFML代码转换为CFScript,但我收到了CFHtmlToPdf的错误.
CFML:
<cfoutput>
<cfhtmltopdf orientation="portrait" pagetype="A4" margintop="1" marginbottom="1" name=pdfFile>
#arguments.data.HTMLData#
</cfhtmltopdf>
<cfmail type=HTML to="#arguments.data.Email#" from="support@mydomain.com" subject="Form Test" server="localhost">
TEST
<cfmailparam file="#arguments.data.ReportName#.pdf" type="application/pdf" content="#pdfFile#"/>
</cfmail>
</cfoutput>
Run Code Online (Sandbox Code Playgroud)
我的cfscript代码:
cfhtmltopdf(source=arguments.data.HTMLData, destination=pdfPath);
mailerService = new mail();
mailerService.setTo("arguments.data.Email");
mailerService.setFrom("support@mydomain.com");
mailerService.setSubject("Form Test");
mailerService.setType("html");
mailerService.addParam(file="Test.pdf",type="application/pdf",content=pdfPath);
mailerService.send(body="Test");
Run Code Online (Sandbox Code Playgroud)
我收到错误:
src不是正确的URL,或者绝对路径指定的文件不存在.
行中出现错误:
cfhtmltopdf(source=arguments.data.HTMLData, destination=pdfPath);
Run Code Online (Sandbox Code Playgroud)
我在cfscript中错误地使用CFHtmlToPdf吗?
问题是你cfhtmltopdf以错误的方式使用.HTML字符串不应该作为source属性传递,而应该作为函数的内容传递(就像你要为a做的那样savecontent).
检查此链接.
variables.pdfFile='';
cfhtmltopdf(name='variables.pdfFile'){
writeOutput(arguments.data.HTMLData);
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
119 次 |
| 最近记录: |