1
 def create_daily_raport(self):

    elements = []
    pdfmetrics.registerFont(TTFont('polishFont', 'polishFont.ttf'))

    data = [['Data', 'nr zlecenia', 'oprawki', 'soczewki', 'zadatek', 'dopłata', 'cena łączna']]

    data_for_table = ['1', '2', '3', '4', '5', '6', '7']
    for i in range(100):
        data.append(data_for_table)

    t = Table(data, 7 * [inch], len(data) * [0.4*inch])
    t.setStyle(TableStyle([('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
                           ('BOX', (0,0), (-1,-1), 0.25, colors.black),
                           ('TEXTFONT', (0, 0), (-1, -1), 'polishFont')]))

    elements.append(t)

    date_to_PDF = self.date_for_PDF_name()

    doc = SimpleDocTemplate("Dzienny_raport_"+date_to_PDF+".pdf", pagesize=A4, rightMargin=2 * cm, leftMargin=2 * cm,
                            topMargin=2 * cm, bottomMargin=2 * cm)
    doc.build(elements, onFirstPage=self.create_footer, onLaterPages=self.create_footer)

I have "polishFont.ttf" in the same folder as this code. Any suggestions why there are still black boxes instead of polish characters?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
xDevil213
  • 33
  • 1
  • 5

1 Answers1

0

Oke I found a mistake.

TEXTFONT was incorect, it should be FONTNAME

xDevil213
  • 33
  • 1
  • 5