Добавлена кодировка специальных символов - PDF Django
У меня есть функция для создания простого PDF. Но при работе со специальными символами она возвращает что-то вроде этого. Как мне правильно сохранить символы типа śćźż в моем pdf-файле?
Я попытался изменить тип шрифта с помощью setFont (Helvetica, TimesRoman) согласно этому doc, но не смог получить ожидаемых результатов.
Views.py (официальный документ)
def some_view_aa(request):
# Create a file-like buffer to receive PDF data.
buffer = io.BytesIO()
# Create the PDF object, using the buffer as its "file."
p = canvas.Canvas(buffer)
# Draw things on the PDF. Here's where the PDF generation happens.
# See the ReportLab documentation for the full list of functionality.
p.drawString(100, 100, "Hello AZX AĄĄŻĄ world.")
# Close the PDF object cleanly, and we're done.
p.showPage()
p.save()
# FileResponse sets the Content-Disposition header so that browsers
# present the option to save the file.
buffer.seek(0)
return FileResponse(buffer, as_attachment=True, filename='hello.pdf')
