[reportlab-users] TTF-Font support

Henning von Bargen H.vonBargen at t-p.com
Tue Mar 19 12:25:02 EDT 2013



> From: Tom Py <mailtank2013 at gmail.com>

> Subject: Re: [reportlab-users] TTF-Font Support

>

> Hi,

>

> regarding my question at the beginning the Font-Support works for me,

but only

> when I print out the pdf directly (Font is originally an otf-font,

convertet

> into afm and pfb-files).

...

>

> But I have first put the pdf into a DB. And from there I give the file

to the

> user. It works with the reportlab standard fonts (Helvetica), but not

with

> additional fonts (Futura in my case).

>

> # via DB

> def createReport()

> ....

>

> # create the report

> pdfStream = createReport()

>

> # save the report in DB

> saveReport(pdfStream):

> sqlStatement = """exec storedProcedure @content='%s' """ %

> (pdfStream.replace("'","''").replace("\r\n","\n"))

> executeNonQuery(sqlStatement)

> return

>

> In this case the pdf opens with the error: 'Cannot extract the

embedded font

> "FuturaStd-Book". Some characters may not display or print correctly.'

> (Note: this way works fine with standard fonts, but not with the

addidional

> font.).

>

>

> Any idea, why this do not work with the additional font?

>


Most likely you treat the PDF as characters, but it's binary data.
And at some stage, non-ascii data gets garbled due to character-set
conversion.

You should treat the PDF as a BLOB.
And the way you code SQL without using bind variables seems error-prone
and insecure anyway...

HTH
Henning




More information about the reportlab-users mailing list