import fpdf
fpdf.set_global("SYSTEM_TTFONTS", os.path.join(os.path.dirname(__file__),'fonts'))
pdf = fpdf.FPDF()
pdf.add_font("NotoSans", style="", fname="NotoSans-Regular.ttf", uni=True)
pdf.add_font("NotoSans", style="B", fname="NotoSans-Bold.ttf", uni=True)
pdf.add_font("NotoSans", style="I", fname="NotoSans-Italic.ttf", uni=True)
pdf.add_font("NotoSans", style="BI", fname="NotoSans-BoldItalic.ttf", uni=True)
pdf.set_font("NotoSans", size=12)
from datetime import datetime
def getFileName():
now=datetime.now()
time = now.strftime('%d_%H_%M_%S')
filename = "Test_"+time + ".pdf"
return filename
from fpdf import FPDF
pdf = FPDF()
#Download NotoSansArabic-Regular.ttf from Google noto fonts
pdf.add_font("NotoSansArabic", style="", fname="./fonts/NotoSansArabic-Regular.ttf", uni=True)
pdf.add_page()
pdf.set_font('Arial', '', 12)
pdf.write(8, 'Hello World')
pdf.ln(8)
# مرحبا Marhaba in arabic
pdf.set_font('NotoSansArabic', '', 12)
text = 'مرحبا'
pdf.write(8, text)
pdf.ln(8)
pdf.output(getFileName(), 'F')