Create PDF with Python | Part 2

preview_player
Показать описание
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:
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

$15 off Annual Dataquest subscription
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

Consider subscribing for weekly tips, tricks, and tutorials.

Join my Discord Server

Check out the official tutorial and documentation that these videos are based on:
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

Link to Fox image (actually it's a raccoon)
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

Github
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

0:00 Intro
0:46 Code Review
1:17 Many lines
2:58 Page Break
3:52 Break Margin
4:11 Header Footer Overview
4:48 Add Header
8:43 Add Footer
9:39 Add Page Number
Рекомендации по теме
Комментарии
Автор

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.



ChartExplorers
Автор

I’m surprised your channel isn’t bigger! Best python tips on YouTube!

chrisbagshaw
Автор

i'm happy because your channel exists

miguelsantiago
Автор

Thanks Man. Your Header and Footer Guide Helped.

usmankhawar
Автор

Hello I'm a newbie in python, how can I fix this issue?

DeprecationWarning: The parameter "ln" is deprecated. Instead of ln=1 use new_x=XPos.LMARGIN, new_y=YPos.NEXT.
pdf.cell(0, 10, f'this line {1} :D', ln=1)

Knight_Sky
Автор

please help me to do make crm database in sqlite3 to pdf, thanks for your response

roamv
Автор

A video on how to make a Table of Content page would be awesome! Thank you for your videos they have been a massive help

joshuathain
Автор

Thanks a lot..!! A fantastic video, a very clear explanation..! Good Job..!! :DD Once again, Thanks..!! Keep it going..!

eduardozaratemontalvo
Автор

In January 2023, the "ln" function for a page break is deprecated. I've found a solution for use with pdf.cell() but don't see how to implement that in the "title" class.

runner
Автор

Sir cannot add the header and footer why help me sir

NebulaLoomVentures
Автор

Watching this video on 8th April 2021. The update to show total page number through nb is here and it is working.

taharataminpronoy
Автор

Reading Image (self.image) stucks the program execution

GaneshJadhav-flzz
Автор

thanks, I have question if I use Arabic language how can write it in code because there is error in code

gammasquare
Автор

Hi everyone, i have one qustion.
How I createA PDF with the canvas from the HTML form?

leonancancela
Автор

Thank u for the video!!! Can you pls explain how to create templates?

the_data_hunter
Автор

Please make more videos, i need the help!!!

rhysbennett
Автор

How do I print a dictionary in pdf using fpdf ?

mr.goldmanbachmajorian
Автор

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

hellofrombd
Автор

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?

TheJonnysmith
Автор

Like you have shown margin at bottom can you tell me how to give margin from Top, i have sample pdf template and i want to append data in that template file. But i have some design at top side of sample template which is not allowing my data to append operation. So can you tell how can i keep margin at top and below that my data frame. If you you can it will be great help! Thanks!!!

vaibhavgandhi