[reportlab-users] Re: windows platypus problem

Andrey Khavryuchenko akhavr at kds.com.ua
Mon Aug 29 13:47:53 EDT 2005


Tim,

"TR" == Tim Roberts wrote:

 TR> On Fri, 26 Aug 2005 19:42:59 +0300, Andrey Khavryuchenko
 TR> <akhavr at kds.com.ua> wrote:

 >> I'm trying to use platypus to handle my pdf output using custom TTF fonts.
 >> But the pdf I get is empty (nothing is shown).
 >> 
 >> The same script under linux (with font path adjusted) works flawlesly.
 >> 
 >> What I'm doing wrong?

 TR> The symptom (different behavior under Windows and Linux) should have
 TR> been a big clue.  Compressed PDF files contain binary data, but you're
 TR> not opening the file in binary mode.  The data get trashed, and
 TR> Acrobat can't read it.  

Shame on me!  Haven't developed for Windows for years..

 TR> Change this:

 TR> open('t.pdf','w').write(fp.getvalue())

 TR> to this:

 TR> open('t.pdf','wb').write(fp.getvalue())

 TR> and all will be well.  

Sure it helped!

 TR> Is there a reason you are going via a StringIO instead of straight to
 TR> the file?

This was barebone stripped orml2pdf.py script.  As soon as I've fixed the
'open' statement, its README rendered perfectly.

Thanks!

-- 
Andrey V Khavryuchenko            http://www.kds.com.ua/
Silver Bullet Software Solutions  http://www.livejournal.com/~akhavr


More information about the reportlab-users mailing list