[xhtml2pdf] empty pdf when run from python console

375 views
Skip to first unread message

Adrian

unread,
Apr 14, 2010, 6:05:02 PM4/14/10
to Pisa XHTML2PDF Support
I'm running Pisa 3.0.32 with Python 2.6.1 on OSX 10.6. I'm trying to
write a couple of simple tests to better understand how pisa works but
am running into issues where empty pdfs are generated when I run pisa
code from the python console.

For instance, if I run the following from the python console, a
blank / empty pdf shows up on my Desktop.

html = "testing <strong>testing</strong>"
filename = "/Users/adrian/Desktop/test.pdf"

import ho.pisa as pisa
pdf = pisa.CreatePDF(html, file(filename, "wb"))


However, if I save the same code to a file (say test.py) and run it
from the Terminal (python test.py), a valid non-blank pdf shows up on
my Desktop. Any idea what might be going on?

I did a search and found a couple of related issues from months ago,
but it was never clear if they were resolved:
http://groups.google.com/group/xhtml2pdf/browse_thread/thread/81dcfb2c2ad32637/88fe9d395ebaa3f4
http://groups.google.com/group/xhtml2pdf/browse_thread/thread/2e8cc120d1883e79/8a75bb90aa27b393

Any help would be greatly appreciated!

Adrian

--
Sie haben diese Nachricht erhalten, da Sie der Google Groups-Gruppe Pisa XHTML2PDF Support beigetreten sind.
Wenn Sie Nachrichten in dieser Gruppe posten möchten, senden Sie eine E-Mail an xhtm...@googlegroups.com.
Wenn Sie aus dieser Gruppe austreten möchten, senden Sie eine E-Mail an xhtml2pdf+...@googlegroups.com.
Besuchen Sie die Gruppe unter http://groups.google.com/group/xhtml2pdf?hl=de, um weitere Optionen zu erhalten.

Dirk Holtwick

unread,
Apr 16, 2010, 11:12:21 AM4/16/10
to xhtm...@googlegroups.com
You need to 'close' the file manually so it is written to disk. Example:

f = file(filename, "wb")
pdf = pisa.CreatePDF(html, f)
f.close()

Dirk

Am 15.04.10 00:05, schrieb Adrian:
Reply all
Reply to author
Forward
0 new messages