开发者

Reportlab PDF version generation problems

开发者 https://www.devze.com 2023-01-23 03:48 出处:网络
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 d

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 P开发者_如何学编程DF 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 $


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号