One the most powerful tools and modules for creating PDFs with python is fpdf2.
today i decided to do something different, i want to put a image and write a text on it, on of my biggest problem i have faced it is, i don't know know the exactly amount of setting, for example, there are some options for image and also the text,(Length, width, height and pixels etc.). first of all , what is your strategy , when you face kind of code when using The above parameters? of course we need to know what is the max and min value for them. its hard for me to understand it.
lets go for my code and take a look at it:
from fpdf import FPDF
class PDF(FPDF):
def header(self):
# Rendering logo:
self.image("/workspaces/110401076/shirtificate/shirtificate.png")
# Setting font: helvetica bold 15
self.set_font("helvetica", "B", 15)
# Moving cursor to the right:
self.cell(80)
# Performing a line break:
self.ln(20)
# We have a title
self.cell(30, 10, "CS50 Shirtificate", border=1, align="C")
def add_txt(self):
txt = input('Name: ')
self.cell(25,50,txt)
# Instantiation of inherited class
pdf = PDF()
pdf.add_page()
pdf.add_txt()
pdf.set_font("Times", size=12)
pdf.output("new-tuto2.pdf")
right here i have problem, because my text printed in the wrong place also my image is too big or too small, i don't know what are the true values.
Notice: If someone had worked with fpdf2, could you please tell me what is cell and write function?
thank you all...