Nadiv Gold Edelstein
Nadiv Gold Edelstein

Reputation: 33

Changing the second argument in setFont() does not change font size - reportlab

My canvas initialization looks like:

canvas = canvas.Canvas(save_name, pagesize=(4032, 3024), bottomup=1)
#canvas.setFont('Helvetica', 12) #set font size and type (not working)
canvas.setFontSize(10000000) #set pt size (not working)

And my drawstring looks like:

canvas.drawString(100, y, line)

where y is a variable and line is a string.

No matter what I set either the setFontSize() argument to or the second argument in setFont(), the size of the font does not change in the PDF.

System: Debian (stretch), Python 3.5.3, Reportlab 3.5.8

EDIT:

Here's that MCVE

canvas = canvas.Canvas(save_name, pagesize=(4032, 3024), bottomup=1)
canvas.setFont("Times-Roman", 20)
text = "foo bar"
canvas.drawString(100, 3000, text)
canvas.save()

Upvotes: 1

Views: 2142

Answers (1)

Nadiv Gold Edelstein
Nadiv Gold Edelstein

Reputation: 33

Solved. Not sure why, but placing the setFont() method right before the drawString() method fixed it.

Upvotes: 1

Related Questions