Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bytes output actually outputs str #220

Open
dmwyatt opened this issue May 24, 2024 · 1 comment
Open

bytes output actually outputs str #220

dmwyatt opened this issue May 24, 2024 · 1 comment

Comments

@dmwyatt
Copy link

dmwyatt commented May 24, 2024

from fpdf import FPDF
def create_minimal_pdf():
    pdf = FPDF()
    pdf.add_page()
    pdf.set_font('Arial', 'B', 12)
    pdf.cell(0, 10, 'Title of the PDF', 0, 1, 'C')
    pdf.set_font('Arial', '', 12)
    pdf.multi_cell(0, 10, 'This is a minimal PDF generated using the FPDF library in Python. '
                          'FPDF is a PHP class which allows to generate PDF files with pure PHP, '
                          'that is to say without using the PDFlib library. FPDF offers all the '
                          'functions needed to generate a PDF file. Here is a simple example.')
    return pdf.output(dest="S")
>>> print(type(create_minimal_pdf()))
<class 'str'>
@Lucas-C
Copy link

Lucas-C commented May 24, 2024

Hi @dmwyatt 🙂

Note that PyFPDF is not maintained anymore.
See #207.
fpdf2 is its successor: https://pypi.org/project/fpdf2/
On GitHub it's there: https://github.com/py-pdf/fpdf2

If you are using pip, switching is very easy:

pip uninstall pypdf
pip install fpdf2

The output of your script will then be:

<class 'bytearray'>

You will also see a few DeprecationWarning warnings explaining what changed compared to PyPDF 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants