Answer the question
In order to leave comments, you need to log in
How to import TFF font into reportlab?
Задал свой TFF стиль шрифта:
# Create the HttpResponse object with the appropriate PDF headers.
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'inline; filename="somefilename.pdf"'
# Create the PDF object, using the response object as its "file."
doc = SimpleDocTemplate(response,
pagesize=A5,
leftMargin=5,
rightMargin=5,
topMargin=5,
bottomMargin=5)
styles = getSampleStyleSheet()
pdfmetrics.registerFont(TTFont('Times', str(settings.BASE_DIR) + '/pdf/static/pdf/TIMES.TTF', 'UTF-8'))
styles.add(ParagraphStyle(name='Justify', alignment=TA_JUSTIFY, fontName='Times', fontSize=10))
styles.add(ParagraphStyle(name='Justify-Bold', alignment=TA_JUSTIFY, fontName='Times-Bold'))
flowables = []
text = "Приложение 5" \
"\n к Приказу" \
"\n Министерства здравоохранения" \
"\n и социального развития" \
"\n Российской Федерации" \
"\n от 22.11.2004 N 255"
para = Paragraph(text.encode('utf-8'), style=styles["Justify"])
TTF file "/home/pi/mis_asp/mis_asp/pdf/static/pdf/TIMES.TTF": invalid checksum 0XFEDD8420 (expected 0xB1B0AFBA) len: 82010 &3: 2
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question