Python

Create PDF with Python | Part 2



How to create a pdf with Python using the simple library FPDF2. This is part 2 of a 4 part series where we go over how to create a pdf with Python and eventually automate the creation of reports and invoices. In this video we go over how to add an image, auto page breaks, headers, and footers (including page number and total page count).

Part 1 of this tutorial:

Consider subscribing for weekly tips, tricks, and tutorials….

Similar Posts

10 thoughts on “Create PDF with Python | Part 2
  1. Hi everyone, fpdf2 has fixed the page number bug if if you have fpdf2 version 2.3.1 or greater you will now get the following error.
    TypeError: alias_nb_pages() missing 1 required positional argument
    What we can do is change our page number in the footer method to:
    self.cell(0, 10, f'Page {self.page_no()}/nb', align='C')

    And then add the argumuent alias ='nb' when we call the alias_nb_pages method.

    pdf.alias_nb_pages(alias='nb')

  2. Thanks for the videos, my header isn't show up at all, nothing under the class is included in the PDF, it's like the code just ignores the whole class. I'm also getting a swiggerly line under the "fpdf" in the top line "from fpdf import FPDF". With the error the import couldn't be resolved. Any ideas?

  3. On pdf.alias_nb_pages() I get the following TypeError: alias_nb_pages() missing 1 required positional argument: 'alias' .What am I doing wrong because I looked at a vew examples and all of then do not have anything define in the ()?

  4. Great series, looking forward to the next ones.
    I have been looking for a python pdf template making method and this will really help.
    It seems like there are very few ways of dealing with pdfs in python, do you know the reason for this?
    Anyways, thanks!

  5. Would you please Create a video about regular expression,how to extract specific word from a cell. Specially (.+?) what does it means and others. ๐Ÿ˜Š๐Ÿ˜Š

Leave a Reply

Your email address will not be published. Required fields are marked *