2

I have Python 3.6 and want to know how to convert 30+ pdf images into jpgs. I have these pdf images stored in one folder and would like to run a script to run through all the pdfs, convert them to jpgs and split them out into a new folder.

I tried to test this out on one image (see code below):

from pdf2jpg import pdf2jpg

inputpath = r"C:\Users\Admin-dsc\Documents\Image project\pdfinputs\RWG003209_2 Red.pdf"
outputpath = r"C:\Users\Admin-dsc\Documents\Image project\jpgoutputs"

result = pdf2jpg.convert_pdf2jpg(inputpath, outputpath, pages="1")
print(result)

The code runs fine, but when I look in the folder:

C:\Users\Admin-dsc\Documents\Image project\jpgoutputs 

I see a folder called RWG003209_2 Red.pdf which is empty. I am confused - shouldn't the jpgs be saved here? Have I misunderstood something?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Beansy
  • 23
  • 3
  • 1
    I haven't used the library so I am just guessing but whitespace in path might be causing problems(`Image project` and file name in your case) Can you try with a folder and file that doesn't have whitespace in it? (and yes I see you are using raw strings but still worth a try) – Lafexlos Oct 30 '18 at 18:20
  • What about this other lib? https://stackoverflow.com/questions/46184239/python-extract-a-page-from-a-pdf-as-a-jpeg – Danilo Muñoz Oct 30 '18 at 18:22

0 Answers0