defgenerate_punjabi_pdf(请求): font_path = os.path.join(settings.BASE_DIR, 'static/myapp/css/fonts/Noto_Sans_Gurmukhi/static', 'NotoSansGurmukhi-Regular.ttf')
pdfmetrics.registerFont(TTFont('NotoSansGurmukhi', font_path))
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'inline; filename="punjabi_text.pdf"'
c = canvas.Canvas(response, pagesize=A4)
c.setFont("NotoSansGurmukhi", 16)
c.drawString(100, 750, "ਵਿਰੋਧ ਦੇ ਸਮੇਂ ਫਾਸ਼ੀਵਾਦ")
c.showPage()
c.save()
return response
我尝试过使用不同的库,例如 fpdf2,但旁遮普文本的 Sihari 放错位置,显示转移到下一个字符。