Reportlab PDF版本生成问题

发布于 2024-10-01 04:33:41 字数 548 浏览 1 评论 0原文

我正在使用带有 platypus 的 reportlab PDF 包来生成一些 PDF 文件。在linux服务器和windows盒子上我有相同的python应用程序,相同版本的reportlab包(尽管python版本略有不同 - 2.6.5与2.6.6)。我使用自己的字体,不依赖系统字体。最近,我注意到在这两个平台上生成的 PDF 有点不同 - 与另一个版本相比,一个版本中的某些段落是垂直向上的几个点。

我试图找出这些平台之间的区别,但我未能找到区别。

最后,当我比较PDF文件时,一个文件是PDF 1.3,第二个文件是PDF 1.4版本,所以我认为问题一定是这个。我不知道如何在reportlab中设置PDF版本的任何选项,请任何人指出如何设置生成的PDF文件的正确版本,或者也许设置reportlab输出的一些附加属性?

更新:

使用reportlab版本2.4:

reportlab.__version__: $Id: __init__.py 3649 2010-01-20 14:45:53Z 达米安 $

I am using reportlab PDF package with platypus to generate some PDF files. On linux server and on windows box I have the same python application, same version of reportlab package (although slightly different python version - 2.6.5 vs 2.6.6). I am using my own fonts, I do not depend on system fonts. Lately, I have noticed that PDF generated on these two platforms are a bit different - some paragraphs are a few points vertically up in one version compared to the other version.

I was trying to found what is the difference between these plaforms, but I have failed to find difference.

Finally, when I compare PDF files, one file is PDF 1.3 and second is PDF 1.4 version so I think that problem must be this. I am not aware of any option how to set PDF version in reportlab, please can anyone point me out how to set proper version of generated PDF file, or maybe to set some additional properties of reportlab output?

UPDATE:

using reportlab version 2.4:

reportlab.__version__: $Id: __init__.py 3649 2010-01-20 14:45:53Z damian $

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风筝在阴天搁浅。 2024-10-08 04:33:41

您是否尝试在每个系统上使用确切的代码生成它们?我在reportlab源代码中进行了快速搜索,发现一些注释指出,如果您使用setFillAlphasetStrokeAlpha方法,那么它将导致生成PDF 1.4而不是1.3.

编辑:

进一步看,我相当确定这些方法是 reportlab 生成 PDF 1.4 文件的唯一原因。否则似乎总是默认为 1.3。据我所知,没有允许您切换版本的界面。但是,您可以很容易地修改源代码来做到这一点。只需搜索 pdfdoc.py 并将此行(在 reportlab 2.5 中的第 85 行左右)从

PDF_VERSION_DEFAULT = (1, 3)

更改

PDF_VERSION_DEFAULT = (1, 4)

为这将强制它始终生成 PDF 1.4 文档。

希望这有帮助。

Are you attempting to generate them with the exact code on each system? I did a quick search in the reportlab source code and found some comments stating that if you utilize the setFillAlpha or setStrokeAlpha methods then it will cause a PDF 1.4 to be generated instead of 1.3.

Edit:

Looking further, I'm fairly certain that these methods are the only reason reportlab would ever generate a PDF 1.4 file. It seems to always default to 1.3 otherwise. As far as I can see there is no interface which would allow you to switch versions. However, you could modify the source pretty easily to do so. Just search for pdfdoc.py and change this line (It is around line 85 in reportlab 2.5) from

PDF_VERSION_DEFAULT = (1, 3)

to

PDF_VERSION_DEFAULT = (1, 4)

This will force it to always generate PDF 1.4 documents.

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文