Python Forum
cyrillic symbols in tables in reportlab.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
cyrillic symbols in tables in reportlab.
#6
(Mar-20-2019, 07:36 AM)hiroz Wrote: It's working! It turned out that under registering the fonts, here is this row:
pdfmetrics.registerFont(TTFont('FreeSans', 'FreeSans.ttf'))
It picks up the font from the folder from which it is launched. This font wasn't there, so it didn't work. Why does it output Russian strings using DrawString when there is no font in the folder is a good question, but I have no answer. Here is an example of working code:
from reportlab.lib import colors
from reportlab.lib.pagesizes import letter
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
def table_fonts():
    doc = SimpleDocTemplate("table_fonts.pdf", pagesize=letter)
    story = []
    data = [['ф_{}'.format(x) for x in range(1, 6)],
    ['фф', 'ф', 'ф', 'ф', 'ф']
    ]
    tblstyle = TableStyle([('FONT', (0, 0), (-1, 1), 'DejaVuSerif', 24)
    ])
    tbl = Table(data)
    tbl.setStyle(tblstyle)
    story.append(tbl)
    doc.build(story)
if __name__ == '__main__':
    pdfmetrics.registerFont(TTFont('DejaVuSerif', 'DejaVuSerif.ttf'))
    table_fonts()
make sure that the “DejaVuSerif.ttf" is in the folder next to the file. All the blessings

GOD BLESS YOU!!! Big Grin Cool Surfing
I tried for a couple of days without any resuts until I found your post.
I was trying to make(and in the end I managed to make)a software that can make a simple packaging label with ean13 barcode, title (translated in 4 languages with google translate), other specs and logo on it.

I had to make around 700 labels very quick because the truck was waiting at the warehouse, the products could be received because they camed without proper labels....so....being a graphic designer with few friends working in the coding area I started to make a python soft/script.

I managed to make the software but because I had bulgarian and maghiar languages, It was giving me black squares instead of letters...

So here YOU come and save my day and the truck drivers day! After staying at the warehouse waiting for my labels to land the products..

Real life story!! :)
Reply


Messages In This Thread
cyrillic symbols in tables in reportlab. - by hiroz - Mar-19-2019, 06:09 PM
RE: cyrillic symbols in tables in reportlab. - by bradmalcom - Sep-10-2020, 04:57 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python script that deletes symbols in plain text nzcan 3 699 Sep-05-2023, 04:03 PM
Last Post: deanhystad
  [SOLVED] Looking for documentation on Reportlab's canvas.transform() function NeilUK 1 615 Aug-23-2023, 01:21 PM
Last Post: NeilUK
  Right to left alignment in python report using Reportlab jalal0034 1 1,841 Sep-27-2022, 04:25 AM
Last Post: jalal0034
Question Trouble installing modules/libraries and getting Notepad++ to show cyrillic letters Dragiev 6 2,260 Jul-24-2022, 12:55 PM
Last Post: Dragiev
  Label Maker FPDF, Reportlab jamesaarr 1 2,670 Aug-09-2021, 11:57 PM
Last Post: Pedroski55
  Using Reportlab to create a landscape pdf SmukasPlays 2 5,443 Aug-09-2020, 09:31 PM
Last Post: SmukasPlays
  Unexpected output: symbols for derivative not being displayed saucerdesigner 0 2,055 Jun-22-2020, 10:06 PM
Last Post: saucerdesigner
  Help! - How to create a Title for a Reportlab Table crabbylou 0 5,351 Mar-29-2020, 09:14 PM
Last Post: crabbylou
  ReportLab Polypop77 0 1,839 Mar-20-2020, 01:17 PM
Last Post: Polypop77
  Replacing symbols by " Tiihu 1 1,880 Feb-13-2020, 09:27 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020