Hi,
so I've started using xhtml2pdf yesterday. I had some really simple html code which I would like to render to pdf for testing purposes.
I've found out that calling the pisa.CreatePDF with the same file as input results in a PDF file which is a bit different each time I call the pisa.CreatePDF
for testing purposes I have this simple Python program:
#!/usr/bin/env python
from xhtml2pdf import pisa
import StringIO
lastlen = 0
def helloWorld(i):
global lastlen
filename = __file__ + ".pdf"
strobj = StringIO.StringIO()
with open('rep.html') as f:
pdf = pisa.CreatePDF(
f.read(),
strobj)
different = lastlen != strobj.len
if different:
with open('rep_%d.pdf' % i, 'wb') as f:
strobj.seek(0)
f.write(strobj.buf)
print "len\t%d\t%s" % (strobj.len, '!!' if different else '')
lastlen = strobj.len
#file(filename, "wb"))
and here is the example result:
len 3279 !!
len 3285 !!
len 3279 !!
len 3273 !!
len 3279 !!
len 2382 !!
len 3279 !!
len 3291 !!
len 3285 !!
len 3295 !!
and there are some screenshots of the PDF files:
and there's the pip freeze result:
Pillow==2.0.0
argparse==1.2.1
html5lib==0.95
pyPdf==1.13
reportlab==2.7
wsgiref==0.1.2
xhtml2pdf==0.0.5
any suggestion WHY THE HELL is the resulting file different each time?!