I have many folders and inside that i have many images. Now i want one PDF per folder so that all images contained in folder goes into PDF. I have 1000s of folders so i want something which can batchprocess or which can walk in the folder and start processing things.
Right-click the folder to show the context menu. Click 'Combine to one PDF' menu option. And choose 'Convert and combine all files into one continuous PDF file' option and click 'Continue'. From the 'Save As' dialog box, choose a folder path and name of the PDF file to be created.
Convert multiple files into a single PDF. Open your favorite web browser and navigate to Acrobat. Select Combine Files. Drag and drop your files into the conversion frame. You can also locate your files manually.
I'd solve this with ImageMagick, and not with Python. ImageMagick has the console tool 'convert'. Use it like this:
convert *.jpg foo.pdf
See here. (Depends on whether you use Windows, Mac or Linux, should be easy to find out with Google)
I used this code to do the same thing. It uses the Python (2.7 not Python 3)and the reportlab package downloadable from here http://www.reportlab.com/software/installation/ and loops thru all the subdirectories of what you set "root" to and creates one pdf of all the jpegs in each folder.
import os
from reportlab.pdfgen import canvas
from reportlab.lib.utils import ImageReader
root = "C:\\Users\\Harry\\"
try:
n = 0
for dirpath, dirnames, filenames in os.walk(root):
PdfOutputFileName = os.path.basename(dirpath) + ".pdf"
c = canvas.Canvas(PdfOutputFileName)
if n > 0 :
for filename in filenames:
LowerCaseFileName = filename.lower()
if LowerCaseFileName.endswith(".jpg"):
print(filename)
filepath = os.path.join(dirpath, filename)
print(filepath)
im = ImageReader(filepath)
imagesize = im.getSize()
c.setPageSize(imagesize)
c.drawImage(filepath,0,0)
c.showPage()
c.save()
n = n + 1
print "PDF of Image directory created" + PdfOutputFileName
except:
print "Failed creating PDF"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With