【问题标题】:Polish characters in reportlab tablesreportlab 表中的波兰语字符
【发布时间】:2017-07-17 12:54:23
【问题描述】:
 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)

我在与此代码相同的文件夹中有“polishFont.ttf”。有什么建议为什么仍然有黑框而不是波兰字符?

【问题讨论】:

    标签: python-3.x character reportlab polish


    【解决方案1】:

    好吧,我发现了一个错误。

    TEXTFONT 不正确,应该是 FONTNAME

    【讨论】:

      猜你喜欢
      • 2013-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-09
      • 2017-11-29
      • 2016-04-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多