
[英]When exporting PDF with CFChart images in ColdFusion It shows embedded font error
[英]cfchart not printing in PDF
我正在尝试使用cfdocument从HTML打印PDF。 当我通过localhost访问代码时,代码工作正常,但是当我使用静态IP在同一台服务器上对其进行在线测试时,它会超时。
我尝试了cfhtmltopdf
它没有超时,但没有生成图表,并显示“图像丢失图标”。 既不会生成图表,也不会生成图像。 文本可以正常打印。 使用图像或图表时,生成PDF大约需要20到30秒。
我在32位和6位CF11上都尝试过同样的问题。 即使最简单的代码也会失败:
<cfhtmltopdf>
<!DOCTYPE html>
<html>
<body>
<div class="pdf_logo" style="margin-bottom: 20px;">
<a href="##"><img src="images/logo.png" width="180"></a>
</div>
</body>
</html>
</cfhtmltopdf>
您的问题可能与图像路径的分辨率有关。 尝试使用绝对路径(http://)或文件路径(file:\\)...尝试从服务器本身的桌面解析图像。
请记住,服务器内部必须将您的images / logo.png解析为。 如果(例如)您生成cfm的pdf文件位于非根目录下,则服务器可以将其解析为http://blah.com/ 一些文件夹 /images/logo.png-由于存在那里没有“图像”文件夹。
还有其他可能性吗? 您的服务器无法解析“内部”修饰语地址,或者正尝试通过防火墙接口使用外部非修饰语地址。
幸运的是,几乎所有这些问题都可以轻松测试或解决。 您还可以通过简单地使用file方法将任何资源包括到PDF文件中来避免麻烦。
有关解析问题的更多信息,请参阅我关于网络地址解析和Cfdocument的文章 。
希望这可以帮助! 祝好运。
我在cfhtmltopdf中遇到了类似的问题。 就我而言,我使用的是cfimage标记,并且图像偶尔会在PDF文档中呈现。
我怀疑cfhtmltopdf标记的呈现是异步发生的,与该标记内部可能发生的任何呈现(例如cfimage或cfchart)不在一个单独的线程中。 因此cfhtmltopdf标记将完成渲染,并且不会获得cfimage或cfchart的渲染结果,因此将显示“残破的图像”图标,因为找不到源。
因此,基于ColdFusion文档†的此解决方案可能会帮助您:
<!--- 1. Generate the chart as a jpeg image. --->
<cfchart name="myChart" format="jpg">
<cfchartseries type="pie">
<cfchartdata item="New Vehicle Sales" value=500000>
<cfchartdata item="Used Vehicle Sales" value=250000>
<cfchartdata item="Leasing" value=300000>
<cfchartdata item="Service" value=400000>
</cfchartseries>
</cfchart>
<!--- 2. Write the jpeg image to a temporary directory. --->
<cffile
action="write"
file="#ExpandPath('/charts/vehicle.jpg')#"
output="#myChart#" />
<!--- 3. Generate the PDF file. --->
<cfhtmltopdf>
<!DOCTYPE html>
<cfoutput>
<html>
<body>
<div class="chart">
<!--- This image tag refers to the file created by cffile --->
<img src="/charts/vehicle.jpg" />
</div>
</body>
</html>
</cfoutput>
</cfhtmltopdf>
†根据此处的示例: http : //help.adobe.com/zh_CN/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7934.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.