12

We've got a .net 2.0 web system that dynamically builds pdf files. Some of these files can get pretty large - 12MB+. While processing time isn't a factor, really, the size of the files to be downloaded is in some cases.

For the moment, let's assume that our B-grade pdf library is already making the smallest files that it knows how. (Although, if anyone has any suggestions on that front, do see this related question.)

However, taking the 12MB file in question and sending it though the Acrobat distiller results in a roughly 700K file, with no appreciable loss in print quality.

I'd love to have some kind of post-processor that does even a third of that. Does anyone have any controls they know about that'll do something like this?

The cheaper the better, for this project, but we're not adverse to throwing a few bucks down.

(Some preemptive comments: naturally, rewriting the existing PDF generation code with a new tool is off the table at the moment. Also, while Distiller seems to have an API, calling that on a webserver doesn't seem like the most efficient course - and Distiller is a little pricey. Finally, we'd just as well not wrap the pdfs in a zip file or some such, since that may baffle the clients somewhat. No, really.)

Thanks!

4

11 回答 11

18

使用Ghostscript,它也可用于 32 位和 64 位 Windows 平台。它识别所有Adob​​e Distiller参数 [1] 并尊重其中的大部分。最重要的是,您可以将 PostScript 程序注入到转换过程中。我在图像密集型 PDF 的预印制作环境中使用了一年。如果参数设置正确,文件大小可以从 40MB 下降到 800kB,而没有明显的质量损失。我发现它非常快,实际上文档指出它可能比 Adob​​e Distiller 更快

它是免费的(就像啤酒和演讲一样)。

[1] 请参阅Distiller帮助文件夹中的distparm.pdf或查看此处

你如何使用它

您可以从命令行使用所有想要的参数、输入和输出文件调用它,然后就完成了。

快速示例:

gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite\
   -dCompatibilityLevel=1.3 -dEncodeColorImages=true\
   -sOutputFile=output.pdf input.pdf

一些有价值的资源:

于 2009-03-04T22:37:30.693 回答
2

PDF 通常使用 JBIG/JBIG2/JPEG2000 压缩。Cvision 的PDFCompressor是压缩 PDF 的最佳选择。

于 2009-03-04T21:49:38.733 回答
2

有多种风格的 PDF 具有不同大小的功能权衡。如果您要转换基于文本的文档(word/excel/etc)与图像文档(TIFF/JPG/BMP/etc),那么它可能会解释 distiller 为您提供的较小文件大小。您需要确保您的实用程序不仅仅是从所有内容中创建仅图像 PDF 文件(通常更大)。压缩格式也非常重要,特别是对于彩色文档。寻找允许您调整这些设置的配置选项。如果您提到特定的 PDF 构建器工具,我们可能会在这方面为您提供更具体的帮助。

以下是关于 PDF 文件“风味”的不错参考:

于 2009-03-04T22:27:08.737 回答
1

大型 PDF 文件有不同的原因。通常的嫌疑人是重复的对象,如图像、不需要的/太大的字体以及太大/压缩不良的图像。

您可以尝试使用市场上可用的 PDF 库之一自己实现压缩实用程序。或者您可以尝试 Docotic.Pdf 库来完成这项任务。我为公司工作,所以你不必信任我 :-) 自己尝试一下,看看它是否对你有帮助。我们有Docotic.Pdf 提供的关于优化手段的 C# 和 VB.NET 压缩 PDF 文档。

免责声明:我知道这个问题已经过时了,但希望我的回答能让那些仍然可以在 SO 上或通过 Google 找到它的人受益。

于 2021-03-18T07:24:05.683 回答
0

如果您的 pdf 库正在制作次优 PDF,那么在任何其他库中加载和保存 PDF 应该会为您提供更小的文件。 PDFNet SDK Type 3 应该可以胜任这项任务,360 美元的价格比 Adob​​e PDF 库便宜。

于 2009-03-04T23:51:33.057 回答
0

Apago 有很多“整理”PDF 的工具

http://www.apagoinc.com/

于 2009-03-05T08:16:00.350 回答
0

File a bug with the maker of your pdf library? If it's open source, fix a couple of the low hanging fruit (there are probably many) and submit a patch?

于 2009-03-04T21:46:53.200 回答
0

I don't have a specific answer to your question, so I hope that my response is not poor form.

I've used pdftk for a variety of PDF-related tasks. It's easy to use from the shell and I see that it does have a compression feature. You could try it out quickly to see if it's something that would work for post processing for your application.

于 2009-03-04T21:48:22.043 回答
0

如果您对无损压缩感兴趣,请尝试我的工具Precomp和您选择的文件压缩器。根据您的 PDF 文件中的内容,Precomp 通常会放大您的 PDF 文件,以便之后可以更好地压缩它。

于 2009-03-04T21:53:46.180 回答
0

除了使用另一个库之外,最好的办法是让您的库正常工作。关于您的另一篇文章的一些建议-我不确定您要运行任何“后期处理”来压缩文件。

顺便说一句,您的网络服务器是否允许 HTTP gzipped 内容?对最终用户透明!

(话虽这么说,短 PDF 文件应该不受大多数​​压缩方法的影响——图像应该在渲染期间被压缩(在这种情况下是 JPEG >> ZIP)——但如果你有很多文本,gzip 可以提供帮助)

于 2009-03-04T22:48:32.553 回答
0

不要在 PDF 中包含整个字体。照顾好那个可以节省几兆字节。

于 2009-03-04T22:59:51.683 回答