0

my code is this

    from reportlab.lib.styles import getSampleStyleSheet
    from reportlab.platypus import BaseDocTemplate, Frame, PageTemplate, Paragraph
    from reportlab.lib.styles import ParagraphStyle
    from reportlab.lib.colors import Color
    from reportlab.pdfbase import pdfmetrics
    from reportlab.pdfbase.ttfonts import TTFont
    pdfmetrics.registerFont(TTFont('Vera', 'Vera.ttf'))
    pdfmetrics.registerFont(TTFont('VeraBd', 'VeraBd.ttf'))
    canvas.setFont(font_name_from_dict , font_size)
    bodyStyle = ParagraphStyle('Body', fontName = "Vera", fontSize= 10, textColor= Color( 255,0,0,1)

    P = Paragraph("większość zmieniła się Έ Ή Ί Ό Ύ Ώ ΐ Α Β Γ Δ Ε Ζ Η Θ Ι Κ" , bodyStyle)
    P.drawOn(canvas, 0, 0)

But I am not able to write paragraph with this characters "większość zmieniła się Έ Ή Ί Ό Ύ Ώ ΐ Α Β Γ Δ Ε Ζ Η Θ Ι Κ" ... I tried with the fonts which support this characters ...Still the problem is same..I am getting [][][][] empty boxes for these letter in pdf

Dark Matter
  • 190
  • 2
  • 13
  • I tried with supporting Fonts also but its not working – Dark Matter Feb 19 '16 at 04:58
  • please put a little more effort into introducing your problem before posting code – Neuron Feb 19 '16 at 05:23
  • Possible duplicate of [Report Lab can't handle hebrew (unicode)](http://stackoverflow.com/questions/10958904/report-lab-cant-handle-hebrew-unicode) – Oliver W. Feb 19 '16 at 05:52
  • @Neuron: What info u need ? – Dark Matter Feb 19 '16 at 06:15
  • @Oliver: I have tried with supporting fonts too but its not working – Dark Matter Feb 19 '16 at 06:15
  • I don't know python well enough to answer your question, I just pointed out that for anyone who does your question is structured poorly and you could improve the chances of someone answering by following [these](http://stackoverflow.com/help/how-to-ask) guidelines – Neuron Feb 19 '16 at 06:18
  • You will probably need to use the unicode representation of those characters to make sure that reportlab links them to their correct symbol. You might also want to check out my answer on another unicode related answer http://stackoverflow.com/a/35371704/2263652 – B8vrede Feb 19 '16 at 08:26

1 Answers1

0

By adding DejaVuSans Font to my application solved my problem Here is the snippet of code

pdfmetrics.registerFont(TTFont('DejaVuSans','DejaVuSans.ttf'))
Dark Matter
  • 190
  • 2
  • 13
  • Please don't copy and paste the same [answer](http://stackoverflow.com/a/35499784/189134) between multiple posts. Instead customize each one to answer the question the OP is asking. – Andy Feb 20 '16 at 03:56