-
Notifications
You must be signed in to change notification settings - Fork 528
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
How can I add page numbers to PDF document? #168
Comments
Override the add_page() method and the footer() method then add a condition parameter (isCover ?) for footer page as example below from FPDF import *
class MyFPDFClass(FPDF):
def __init__(this, orientation='P',unit='mm',format='A4'):
self.isCover = False
# Override add_page methode
def add_page(this, same= True, orientation='', isCover= False):
FPDF.add_page(self, same= same, orientation=orientation)
# Override footer method
def footer(self):
# Page number with condition isCover
self.set_y(-15) # Position at 1.5 cm from bottom
if self.isCover == False:
self.cell(0, 10, 'Page ' + str(self.page_no) + ' | {nb}', 0, 0, 'C')
# Then call instruction with this instance line of your class :
# myfpdfclass.add_page(isCover = False)
# or
# myfpdfclass.add_page(isCover = True) |
Thanks! I will try this |
FYI, this recipe is documented here in |
is there no way to use function instead of class to handle it |
With |
I would like to add page numbers at the bottom of every page (except the first one which is a cover).
I was wondering if it's possible to do this using pyfpdf?
The text was updated successfully, but these errors were encountered: