add_page() not accepting the parameters for width and height of the page in FPDF

403 Views Asked by At

I was converting a number of images to pdf using FPDF in python, however doing:

pdf.add_page('P',x,y)

(x and y are well defined and have values, pdf = FPDF())

Returns the following error:

Traceback (most recent call last):
  File "/home/kali/Documents/image to pdf.py", line 72, in <module>
    pdf.add_page('P',x,y)
TypeError: add_page() takes from 1 to 2 positional arguments but 4 were given

Checking the source of the function FPDF.add_page():

>>> print(inspect.getsource(FPDF.add_page))
    def add_page(self, orientation=''):

(there was more to it, cropped the main code.)

However the documentation seems to state otherwise:

fpdf.add_page(orientation = '', format = '', same = False)

format:
...or a tuple containing the width and the height (expressed in the given unit). In portrait orientation, the tuple should be in the order (width, height), but in landscape orientation, the order should be (height, width)...

What might I be missing?

0

There are 0 best solutions below