[英]Size of pdf generated with reportLab
I have a problem with the generation of my pdf. 我在生成pdf时遇到问题。
When I generate a pdf and after few minute when I restart the same script to generate the same pdf I don't have the same size between my first pdf and the second... 当我生成pdf并在几分钟后重新启动相同的脚本以生成相同的pdf时,我的第一个pdf和第二个pdf之间没有相同的大小...
this is my code : 这是我的代码:
c = reportlab.pdfgen.canvas.Canvas("test.pdf")
c.showPage()
c.save()
The first pdf have : 1519
byte 第一个pdf有:
1519
字节
And the second have 1531
byte 第二个有
1531
个字节
Whenever I restart the same script and whenever I have differents value. 每当我重新启动相同的脚本并且每当我具有不同的值时。 Why?
为什么? How can I resolve it?
我该如何解决?
I don't see your problem of the PDF changing size, but its contents are changing: 我看不到您的PDF大小更改问题,但是其内容正在更改:
$ python make_pdf.py && md5sum test.pdf
9a1dbc5621622526b4411fb5f818246e test.pdf
$ python make_pdf.py && md5sum test.pdf
b4c3ef4661c2a0f7d5c458757ac8a891 test.pdf
$
Following the hint from your comment, setting the invariant
option solves that. 根据您的注释提示,设置
invariant
选项即可解决该问题。
import reportlab.pdfgen.canvas
import reportlab.rl_config
reportlab.rl_config.invariant = 1
c = reportlab.pdfgen.canvas.Canvas("test.pdf")
c.showPage()
c.save()
Now the contents don't change, because the PDF doesn't get a generated id, and the timestamp is set to 0:00 01 Jan 2000 UTC. 现在,内容不会更改,因为PDF没有获得生成的ID,并且时间戳记设置为2000 UTC Jan 01 UTC。
$ python make_pdf.py && md5sum test.pdf
4a0ecf533e69fc2a91cda0a055cbec58 test.pdf
$ python make_pdf.py && md5sum test.pdf
4a0ecf533e69fc2a91cda0a055cbec58 test.pdf
$
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.