Reputation: 31
I am using Python and I'm trying to place three images that cover the entire page. The last image creats and jumps to the next page, I think beacuse of the 'footer'. How can I disable this footer or overcome it?
from PIL import Image
from fpdf import FPDF
class PDF(FPDF):
pass
def imagex(self):
self.set_xy(0, 0)
self.image(fr'C:\Users\user\Desktop\pictures\1.jpeg', link='', type='', w=210, h=100)
self.set_xy(0, 100)
self.image(fr'C:\Users\user\Desktop\pictures\2.jpeg', link='', type='', w=210, h=100)
#This is where the picture jumps
self.set_xy(0, 200)
self.image(fr'C:\Users\user\Desktop\pictures\3.jpeg', link='', type='', w=210, h=100)
if __name__ == '__main__':
pdf = PDF()
pdf.add_page()
imagex(pdf)
pdf.output(r'C:\Users\user\Desktop\test.pdf', 'F')
Upvotes: 0
Views: 544
Reputation: 303
You can use this below solution:
def imagex(self, w, h):
w_Image=w
h_Image=h
self.image(fr'C:\Users\user\Desktop\pictures\1.jpeg', 0, 0, w=w_Image, h=h_Image)
self.image(fr'C:\Users\user\Desktop\pictures\2.jpeg', 0, h_Image, w=w_Image, h=h_Image)
self.image(fr'C:\Users\user\Desktop\pictures\3.jpeg', 0, h_Image*2, w=w_Image, h=h_Image)
if __name__ == '__main__':
pdf = PDF()
pdf.add_page()
imagex(pdf,210,100)
pdf.output(r'C:\Users\user\Desktop\test.pdf', 'F')
I tried to rewrite your code and assessed based on my data. In fact, you must set the location of each picture sequentially. Instead of using self.set_xy
I embedded (x,y)
location in self.image("file_path", x,y, w,h)
Upvotes: 1