[reportlab-users] Problem with embedded font, help needed

Robin Becker robin at reportlab.com
Mon Aug 24 11:15:45 EDT 2009

Dinu Gherman wrote:

> Roberto Alsina:


>> It was a StringIO which I think uses cStringIO if it's available, and

>> python

>> 2.6.


>> Anyway, it's not worth the problem even to debug unless you really,

>> really,

>> really want to avoid creating a tempfile (say, if you are in google app

>> engine).



> I'm saving lots of PDFs into cStringIO.StringIO objects (also

> using DejaVuSans) and I never observed this issue, so far...


I think Dinu is right here; unless some kind of string conversions are going on
it should be OK to write PDFs into a filelike object such as StringIO.StringIO
and read it back without problems.

Indeed internally fonts are often handled that way eg ttfonts.py

> def makeStream(self):

> "Finishes the generation and returns the TTF file as a string"

> stm = StringIO()

where the subset fonts are created as filelike objects. All the writes are done
using the stm.write method though.

> BTW, saving to memory should be much faster than to and from

> a disk, and it helps extending the life time of your disk.


> Regards,


> Dinu


Robin Becker

More information about the reportlab-users mailing list