title: Build a Python class for FPDF
body: <p>I want to use the Python library <a href="https://pypi.org/project/fpdf2/" rel="nofollow noreferrer">fpdf2</a> and build my own class to generate a pdf document. I tried this:</p>
  <pre><code>from fpdf import FPDF   
  
  class MyPdf(FPDF):
      def __init__(self, *args, **kwargs):
              super().__init__()
              self.pdf = FPDF()
              self.pdf.add_page()
              # customize pdf
      def OtherCustomization(self):
              self.pdf.add_page()
              # other customization pdf
  
  
  pdf1 = FPDF()
  pdf1.add_page()
  
  pdf2 = MyPdf()
  pdf2.add_page()
  pdf2.OtherCustomization()
  
  pdf1.output(&quot;1.pdf&quot;)
  pdf2.output(&quot;2.pdf&quot;)
  </code></pre>
  <p>I expect a file 1.pdf with one page, another 2.pdf with two pages, but it does not work.</p>
  <pre><code># pdfinfo 1.pdf | grep Pages
  Pages:           1
  # pdfinfo 2.pdf | grep Pages
  Pages:           1
  </code></pre>