from fpdf import FPDF

pdf = FPDF("P", "mm", "A4")
pdf.add_page()
pdf.set_font("Arial", "B", 16)
pdf.cell(40, 10, "Hello", border=1)

pdf_str = pdf.output("", "S")  # save to file

with open("from_str.pdf", "wb") as f:
    f.write(pdf_str)

ff9ad06640f8ae3f0e2daabe8252d199a710722f
<mask token>

<mask token>
pdf.add_page()
pdf.set_font('Arial', 'B', 16)
pdf.cell(40, 10, 'Hello', border=1)
<mask token>
with open('from_str.pdf', 'wb') as f:
    f.write(pdf_str)

<mask token>
pdf = FPDF('P', 'mm', 'A4')
pdf.add_page()
pdf.set_font('Arial', 'B', 16)
pdf.cell(40, 10, 'Hello', border=1)
pdf_str = pdf.output('', 'S')
with open('from_str.pdf', 'wb') as f:
    f.write(pdf_str)

from fpdf import FPDF
pdf = FPDF('P', 'mm', 'A4')
pdf.add_page()
pdf.set_font('Arial', 'B', 16)
pdf.cell(40, 10, 'Hello', border=1)
pdf_str = pdf.output('', 'S')
with open('from_str.pdf', 'wb') as f:
    f.write(pdf_str)

from fpdf import FPDF

pdf = FPDF("P", "mm", "A4")
pdf.add_page()
pdf.set_font("Arial", "B", 16)
pdf.cell(40, 10, "Hello", border=1)

pdf_str = pdf.output("", "S")  # save to file

with open("from_str.pdf", "wb") as f:
    f.write(pdf_str)
