将 pdf:s 与 pdfBox 合并会创建不必要的大文件
这个主题有大量的点击,但只有蹩脚的线程:(
我用 pdfBox 合并了一堆 pdf 文件。用一个类很容易达到目的。
但结果是一个非常大的文件。我现在没有确切的数字,但它很容易与普通 desctop 应用程序完成的合并相比,
问题
似乎与此类似(在这种情况下拆分,相同但不同): https://issues.apache.org/jira/browse/PDFBOX-785
经过一番谷歌搜索后,我认为问题在于合并生成了一个简单的合并 PDF 文件,而且是一个大文件,没有压缩。
根据这个博客,一些java pdf库可以处理压缩: http://pdf-house.blogspot.com/
Itext 根据 pdfstamper setFullCompression() 处理此问题。 PDF/CompressPdfdocument.htm">http://www.java2s.com/Tutorial/Java/0419_PDF/CompressPdfdocument.htm
但我也遇到了 Ghost 脚本项目。 https://www.linux.com/news/software /applications/8229-putting-together-pdf-files
所以,我需要第二个意见。这个幽灵脚本看起来很酷,但根据谷歌的说法,itext 确实可以做到这一点。
我走在正确的轨道上吗?选择什么?上述其中之一还是完全不同的东西?
嗯!
Massive amount of hit on this topic but only crappy threads :(
I merge a bunch of pdf files with pdfBox. Easy with a class for the purpose.
But the reult is a very large file. I have no exact figure now but its easy twise the size compared to a merge done by a ordinary desctop app.
Not acceptable im afraid.
The problem seems to be similar to this (split in this case, same same but diffrent):
https://issues.apache.org/jira/browse/PDFBOX-785
After some googling I think the problem is that the merge produces a barebones merged PDF file, and a large one at that, without compresson.
According this blog some java pdf libs can handle compression:
http://pdf-house.blogspot.com/
Itext handles this according with pdfstamper setFullCompression().
PDF/CompressPdfdocument.htm">http://www.java2s.com/Tutorial/Java/0419_PDF/CompressPdfdocument.htm
But i also bumped in to the ghost script project.
https://www.linux.com/news/software/applications/8229-putting-together-pdf-files
So, I need a second opinion. This ghost script seems cool, but itext does the trick according to google.
Am I on the right track? What to choose? One of the above or somthing intirely diffrent?
Tnx!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试混合 PDFBox 与 itext 进行合并以进行压缩。
请参阅常规示例: http://pastebin.com/w8Rz8uha
我用 http://www.tobcon.ie/assets/files/test.pdf 和 uncompressed.pdf为 302kb,compressed.pdf 为 58kb。 (100页重复页)
Try mixing PDFBox for merging with itext for compression.
See groovy example: http://pastebin.com/w8Rz8uha
I tested it with http://www.tobcon.ie/assets/files/test.pdf and uncompressed.pdf is 302kb and compressed.pdf is 58kb. (100 duplicated pages)