'PyFPDF can't add page while specifying the size

on pyfpdf documentation it is said that it is possible to specify a format while adding a page (fpdf.add_page(orientation = '', format = '', same = False)) but it gives me an error when specifying a format.

error:

pdf.add_page(format = (1000,100)) TypeError: add_page() got an unexpected keyword argument 'format'

i've installed pyfpdf via pip install and setup.py install but it doesnt work in both ways

how can i solve this?



Solution 1:[1]

When you checked the documentation from python using help() you can find out that add_page() only accept one argument.

add_page(self, orientation='') Start a new page

It seems inconsistent with the documentation they wrote on pypdf. But this happen if you install fpdf via pip. Try install it from github master branch. This should fix it.

Solution 2:[2]

Your problem is that two packages of pypdf exist, fpdf and fpdf2. They both use from fpdf import FPDF, but only fpdf2 has also a format= keyword in the add_page() method.

So you need to install the fpdf2 package.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2