[reportlab-users] Changing fonts for a SimpleDocTemplate
thejaswi.puthraya at gmail.com
Sat Nov 20 01:43:18 EST 2010
Sorry for getting back late. Thanks for the answer but probably it's better
to add a little more context to my question...
On Mon, Nov 15, 2010 at 10:30 PM, <
reportlab-users-request at lists2.reportlab.com> wrote:
> IIRC when you are using platypus,
> it shouldn't be necessary to call canvas.addFont.
> If you want to use that font for your table cells,
> just add
> style.add(*('FONT', (0,0), (-1,-1), TestFont', 10))
> to your code.
The main problem, I currently face is that the Helvetica font on Windows
doesn't display some diacritics for European languages like Slovak. It
replaces the glyph with a box. This problem cannot be reproduced on a linux
based operating system. I am calling reportlab from within a web
So I was thinking of embedding a custom font. Here's how I am trying it and
it doesn't seem to work (I am fairly sure I am missing something)
doct = doctemplate.SimpleDocTemplate("/path/to/output.pdf",
style_sheet = getSampleStyleSheet()
data = 
style = GRID_STYLE
style.add(*('VALIGN', (0,0), (-1,-1), 'MIDDLE'))
style.add(*('LEFTPADDING', (0,0), (-1,-1), 15))
style.add(*('RIGHTPADDING', (0,0), (-1,-1), 15))
table = LongTable(data, colWidths=360, rowHeights=215, style=style)
page_flowables = [table]
canvas = doct.canv
On running this piece of code, I get the following error:
redefining named object: 'toUnicodeCMap:AAAAAA+EurostileExtended-Roman-DTC'
I am not sure I understand this error and how I am redefining this object
when I am calling registerFont only once.
PS: The addFont method not working has still not been answered ;-)
> -----Urspr?ngliche Nachricht-----
> Von: reportlab-users-bounces at lists2.reportlab.com
> [mailto:reportlab-users-bounces at lists2.reportlab.com]Im Auftrag von
> reportlab-users-request at lists2.reportlab.com
> Thejaswi Puthraya wrote:
> I have a simple doc template with two flowables, a paragraph and a long
> table. The PDFs get generated fine but I want to customize the fonts
> (preferably embed them) that are used to display the document. How do I go
> about this task?
> Here is a simple snippet of my code below for context:
> doct = doctemplate.SimpleDocTemplate('test.pdf',
> # data is a list of lists
> data = [...]
> style_sheet = getSampleStyleSheet()
> style = GRID_STYLE
> style.add(*('VALIGN', (0,0), (-1,-1), 'MIDDLE'))
> style.add(*('LEFTPADDING', (0,0), (-1,-1), 15))
> style.add(*('RIGHTPADDING', (0,0), (-1,-1), 15))
> table = LongTable(data, colWidths=360, rowHeights=215, style=style)
> page_flowables = [table]
> canvas = doct.canv
> # canvas.addFont('TestFont')
> canvas.setTitle("Some title")
> We get hold of the canvas object only after the flowables have been built.
> Should the font be changed after building the doc or before and if one of
> these, how?
> Btw, the addFont method on the canvas doesn't work because there is no
> 'addFont' method defined on the PDFDocument class, so there is an error
> raised every time addFont is called on the canvas instance. I don't seem to
> be alone in facing these problem .
> I wanted to raise a ticket for the above problem but couldn't locate a
> ticket tracker.
> reportlab-users mailing list
> reportlab-users at lists2.reportlab.com
> End of reportlab-users Digest, Vol 79, Issue 7
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the reportlab-users