A couple of days ago I started to use ReportLab with Python34. It's pretty nice package but I have one big problem that I don't know how to overcome.
Could someone check my code and help me get over this? The problem is connected with letter č in Slovenian language. In the title there is no problem, but later in pdf file I cannot see that letter.
My code is below:
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.rl_config import defaultPageSize
from reportlab.lib.units import inch
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfgen import canvas
from reportlab.pdfbase.ttfonts import TTFont
pdfmetrics.registerFont(TTFont('Vera', 'Vera.ttf'))
PAGE_HEIGHT=defaultPageSize[1]
PAGE_WIDTH=defaultPageSize[0]
styles = getSampleStyleSheet()
Title = "Izračun pokojnine"
bogustext =("""ččččččččččččččččččč""")
def myPage(canvas, doc):
canvas.saveState()
canvas.setFont('Vera',16)
canvas.drawCentredString(PAGE_WIDTH/2.0, PAGE_HEIGHT-108, Title)
canvas.restoreState()
def go():
doc = SimpleDocTemplate("phello.pdf")
Story = [Spacer(1,2*inch)]
style = styles["Normal"]
p = Paragraph(bogustext, style)
Story.append(p)
Story.append(Spacer(1,0.2*inch))
doc.build(Story, onFirstPage=myPage)
go()
When I make pdf file I get this:
Why there is a difference between letter č in title and text?
Thanks in advance!
Best regards, David