1

I have 190 images, each 1.5 to 3 MB in size and want to make a pdf out of all those images

I was following this Create PDF from a list of images.

Problem is when I try to make pdf of small number of images like up to 20, it works perfect. Though pdf size becomes 35 to 40 MB and it takes considerable amount of time to execute but when I go with like 100 images, it never executes to output pdf file

from fpdf import FPDF
pdf = FPDF('P', 'mm', 'A4')

inp   = 'images'
sstr = open(inp).read()
imagelist = sstr.strip().split()
#print imagelist #list of 190 images
for image in imagelist:
    pdf.add_page()
    pdf.image(image,0,0,210,297)

pdf.output("yourfile.pdf", "F")
Ryabchenko Alexander
  • 10,057
  • 7
  • 56
  • 88
ricky
  • 471
  • 1
  • 5
  • 11

2 Answers2

0

Instead of fpdf, try img2pdf.py

Patrick Maupin
  • 8,024
  • 2
  • 23
  • 42
0

Also you can try to make set of small pdf's and then concatenate them with PyPDF2.PdfFileMerger() from PyPDF2 lib

Ryabchenko Alexander
  • 10,057
  • 7
  • 56
  • 88