cfchart无法以PDF打印 [英] cfchart not printing in PDF

查看:129
本文介绍了cfchart无法以PDF打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用cfdocument从HTML打印PDF.当我通过localhost访问代码时,代码工作正常,但是当我使用静态IP在同一台服务器上对其进行在线测试时,它会超时.

I'm trying to print PDF from HTML using cfdocument. The code works fine when I access it through localhost, but when I use static IP to test it online on the same server it timeouts.

我尝试了cfhtmltopdf,它没有超时,但没有生成图表,并显示图像丢失图标".既不会生成图表,也不会生成图像.文本可以正常打印. 使用图像或图表时,生成PDF大约需要20到30秒.

I tried cfhtmltopdf it didn't timeouts but it doesn't generate the chart and shows "image missing icon". nor charts get generated nor images. text gets printed fine. And it takes like 20 to 30 seconds to generated the PDF when an image or chart is used.

我在32位和11位CF11上都遇到了同样的问题. 甚至最简单的代码也会失败:

I tried this on CF11 32bit and 6bit both having same issue. Even the simplest codes fails:

<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>

推荐答案

我在cfhtmltopdf中遇到了类似的问题.就我而言,我使用的是cfimage标签,并且图像偶尔会在PDF文档中呈现.

I've encountered a similar issue with cfhtmltopdf. In my case, I was using a cfimage tag, and the images were being rendered in the PDF document very sporadically.

我怀疑cfhtmltopdf标记的呈现是异步发生的,与该标记内部可能发生的任何呈现(例如cfimage或cfchart)不在一个单独的线程中.因此cfhtmltopdf标记将完成渲染,并且不会获得cfimage或cfchart渲染的结果,因此将显示残破的图像"图标,因为找不到源.

I suspect that the rendering of the cfhtmltopdf tag happens asynchronously, in a separate thread from any rendering that may happen inside that tag (for example, cfimage or cfchart). So the cfhtmltopdf tag will finish rendering, and it won't have the results from the rendering of cfimage or cfchart, so it displays the "broken image" icon because it can't find the source.

因此,基于ColdFusion文档†的此解决方案可能会为您提供帮助:

So this solution based on ColdFusion documentation† might help you:

<!--- 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

这篇关于cfchart无法以PDF打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆