[reportlab-users] TTF-Font Support
Tom Py
mailtank2013 at gmail.com
Thu Jan 24 05:12:37 EST 2013
Hi Tim,
thats the code:
import os
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A4, landscape
actFolder = os.getcwd() + os.sep
fontFile = 'futural.ttf'
fontName = 'FuturaBT-Light'
pdfmetrics.registerFont(TTFont(fontName, actFolder + fontFile))
myCanvas = canvas.Canvas("test.pdf", pagesize = landscape(A4))
myCanvas.setFont(fontName, 10.)
myCanvas.drawCentredString(100, 100, 'Hello World')
myCanvas.showPage()
myCanvas.save()
#myCanvas.getpdfdata()
In this case, everything works fine. But when I use
'myCanvas.getpdfdata()', I'll get this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\fonttest.py", line 23, in ftest
myCanvas.getpdfdata()
File "C:\Program Files
(x86)\Python273\lib\site-packages\reportlab\pdfgen\canvas.py", line 1201,
in getpdfdata
return self._doc.GetPDFData(self)
File "C:\Program Files
(x86)\Python273\lib\site-packages\reportlab\pdfbase\pdfdoc.py", line 248,
in GetPDFData
fnt.addObjects(self)
File "C:\Program Files
(x86)\Python273\lib\site-packages\reportlab\pdfbase\ttfonts.py", line 1126,
in addObjects
pdfFont.ToUnicode = doc.Reference(cmapStream, 'toUnicodeCMap:' +
baseFontName)
File "C:\Program Files
(x86)\Python273\lib\site-packages\reportlab\pdfbase\pdfdoc.py", line 536,
in Reference
raise ValueError, "redefining named object: "+repr(name)
ValueError: redefining named object: 'toUnicodeCMap:AAAAAA+FuturaBT-Light'
Thanks for help. :)
2013/1/23 Tim Roberts <timr at probo.com>
> Tom Py wrote:
> >
> > currently I try to embed a TT-font (Futura-Font) in my report as
> > described in the user guide (v2.6, 3.5 TrueType Font Support).
> >
> > But all I get is a pdf-file with a blank page an an error message ('An
> > error exists on this page. Acrobat may not display ...').
>
> Can you show us your code? TrueType fonts as a rule work fine, so I'm
> guessing there's some setup problem.
>
> --
> Tim Roberts, timr at probo.com
> Providenza & Boekelheide, Inc.
>
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at lists2.reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20130124/f542afe3/attachment.htm>
More information about the reportlab-users
mailing list