cfchart 不以 PDF 格式打印 [英] cfchart not printing in PDF

查看:16
本文介绍了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.

我在 CF11 32 位和 6 位上试过这个,两者都有同样的问题.即使是最简单的代码也会失败:

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/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7934.html

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

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