On Mon, Nov 30 2020 at 05:20:30 PM, Michael Baca <jester...@gmail.com> wrote: > Hello, new to the group, rather new to programming. > > I'm writing a program that takes images and converts them into PDF's. It > works after quite a few days of trying, however the final file has a blank > page inserted before and after each page containing the images. > > This uses FPDF to do the conversion. I've been up and down trying to figure > out where I'm adding an extra page, so it might be an FPDF issue. > > def multi_convert(pdf_Filename, file_path): > if (dir): > file_list = [] > print(""), print("") > print("Converting... This may take awhile depending on the number of > images.") > > for entry in os.scandir(file_path): > if (entry.path.endswith(".jpg") or entry.path.endswith(".png")) > and entry.is_file(): > file_list.append(entry.path) > else: > print("Error: ") > print("Invalid Directory - {}", dir) > cover = Image.open(str(file_list[0])) > width, height = cover.size > > pdf = FPDF(unit="pt", format=[width, height]) > > for page in file_list: > pdf.add_page()
I've never used FPDF, but have you considered not doing the add_page explicitly here? The documentation at https://pyfpdf.readthedocs.io/en/latest/reference/image/index.html might be useful; see especially the behaviour specified when the "y" parameter is not specified, as in this case. > pdf.image(str(page)) > > pdf.output(file_path + pdf_Filename + ".pdf", "F") > exit() If you're unable to resolve the issue, you should report it to pyfpdf at https://github.com/reingart/pyfpdf/issues (after checking if this is a known problem). -- regards, kushal -- https://mail.python.org/mailman/listinfo/python-list