Здравствуйте, я не могу написать грузинские буквы, когда генерирую pdf, используя django. Мой код пишет черные квадраты помимо грузинских букв.
Я генерирую pdf файлы о каждом объекте модели, но в pdf я не могу писать грузинскими буквами, он возвращает черные квадраты. Вот код, который я использую: from xhtml2pdf import pisa в моем urls.py :path('pdf/', views.customer_render_pdf_view, name='costumer-pdf-view')
def customer_render_pdf_view(request, *args, **kwargs):
pk = kwargs.get('pk')
customer = get_object_or_404(id, pk=pk)
template_path = 'test.html'
context = {'customer': customer}
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'filename= "report.pdf"'
template = get_template(template_path)
html = template.render(context)
pisa_status = pisa.CreatePDF(
html,
dest=response,
encoding='utf-8'
)
# if error then show some funy view
if pisa_status.err:
return HttpResponse('We had some errors <pre>' + html + '</pre>')
return response
Вы просто используете шрифт, в котором нет ваших букв. Вам нужно использовать шрифт, в котором они есть.
https://xhtml2pdf.readthedocs.io/en/latest/reference.html?highlight=Font#using-custom-fonts