压缩由冷融合生成的PDF文档 [英] Compressing a PDF document generated by coldfusion

查看:251
本文介绍了压缩由冷融合生成的PDF文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在大修一个内置在CF8的pdf报告生成应用程序,他们有一个接口,生成一个50页的法律报告作为pdf,并发送大约100x一天。但是,它非常繁琐,并且淹没了已经过度劳累的服务器。有没有一个好的PDF压缩脚本,我可以运行与coldfusion或一种方法与Adobe acrobat集成,以压缩pdf之前服务器通过电子邮件发送pdf?系统已使用可用的Coldfusion资源进行设置,以尝试并帮助此过程,但仍然不够。

I'm trying to overhaul a pdf report generation application built in CF8 and they have an interface which generates a 50 page legal report as a pdf and sends it out about 100x a day. However, its very cumbersome and bogs down an already overworked server. Is there a good PDF compression script that I can run with coldfusion or a way to integrate with Adobe acrobat to have it compress the pdf before the server sends the pdf via email? The system is already setup using the available Coldfusion resources to try and help with this process, but its still not sufficient.

更新:我有机会进一步深入问题。这些文档的编写方式通过4个CF表单,其中有人手动输入法律数据,因为它进入系统。某些表单字段很长(接受超过10,000个字符或更多)。一旦完成,它运行一个cfdocument标记,将一切转换为pdf。

Update: I had the opportunity to further dig into this issue. The way these documents are compiled its via 4 CF forms where someone manually types in the legal data as it comes in to the system. Some of the form fields are lengthy (accepting in excess of 10,000 characters or more). Once completed, it runs a cfdocument tag that converts everything into a pdf.

推荐答案

CFDocument生成blo肿的PDF。我们测试了GhostScript,并使用以下参数将22.3mb PDF压缩为4mb。 (如果设置为屏幕,文件大小进一步缩小到2.5MB。)
http:// www .ghostscript.com /

CFDocument generates bloated PDFs. We tested GhostScript and used the following parameters to compress a 22.3mb PDF to 4mb. (If set to "screen", the file size shrunk down further to 2.5mb.) http://www.ghostscript.com/

要使用此功能,您必须在生成PDF之后执行此优化,并使用cftry /

To use this, you'll have to perform this optimization as an extra step after the generation of your PDF and use cftry/catch in case there are any issues or timeouts.

<CFSET ThePDFFile = "C:\test\OriginalPDF.pdf">
<cfexecute name="c:\Program Files\gs\gs9.14\bin\gswin64.exe"
arguments="-sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -dNOPAUSE -dQUIET -dBATCH -sOutputFile=#replace(ThePDFFile,'.pdf','-opt.pdf')# #ThePDFFile#" timeOut="160">
</cfexecute>

另一个解决方案是使用WKHTML2PDF生成PDF。结果文件小得多。质量在ColdFusion 8-11上是一致的。您可以嵌入TrueType字体,而无需注册它们,它没有任何与CFDocument存在的HTML / CSS怪癖。
http://wkhtmltopdf.org/

Another solution would be to generate your PDFs using WKHTML2PDF. The resultant files are much smaller. The quality is consistent on ColdFusion 8-11. You can embed TrueType fonts without having to register them and it doesn't have any of the HTML/CSS quirks that are present with CFDocument. http://wkhtmltopdf.org/

这里有一篇文章的链接和一些ColdFusion示例代码,您可以使用它来将WKHTMLTOPDF的结果与CFDocument进行比较。
http://gamesover2600.tumblr .com / post / 108490381084 / wkhtmltopdf-demo-to-compare-w-adobe-coldfusion

Here's a link to an article and some sample ColdFusion code that you can use to compare the results of WKHTMLTOPDF to CFDocument. http://gamesover2600.tumblr.com/post/108490381084/wkhtmltopdf-demo-to-compare-w-adobe-coldfusion

这篇关于压缩由冷融合生成的PDF文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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