When printing to a pdf file from txt (utf-8 encoding), the following happens: enter image description here txt2pdf.py:

from reportlab.platypus import SimpleDocTemplate, Paragraph from reportlab.lib.styles import getSampleStyleSheet from reportlab.lib.units import inch from reportlab.lib.pagesizes import letter def txt2pdf(path): styles = getSampleStyleSheet() styleN = styles['Normal'] story = [] pdf_name = 'pdf.pdf' doc = SimpleDocTemplate( pdf_name, pagesize=letter, bottomMargin=.4 * inch, topMargin=.6 * inch, rightMargin=.8 * inch, leftMargin=.8 * inch) try: txt_file = open(path, 'r') except: print('0') text_content = txt_file.read() P = Paragraph(text_content, styleN) story.append(P) doc.build(story) 

    1 answer 1

    You must have registered a Cyrillic font

     from reportlab.pdfbase import pdfmetrics pdfmetrics.registerFont(TTFont('DejaVuSans', 'DejaVuSans.ttf', 'utf-8')) 

    And use it when creating a document.

     body_style = ParagraphStyle('Body', fontName="DejaVuSans", fontSize=10) p = Paragraph(text_content , body_style)