简体   繁体   中英

Convert multiple pdf files in a folder into jpgs in Python

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):

import pdf2jpg as 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)

but I keep getting the following error message which I don't understand:

Traceback (most recent call last):

  File "<ipython-input-27-050be63282af>", line 11, in <module>
    result = pdf2jpg.convert_pdf2jpg(inputpath, outputpath, pages="1")

AttributeError: module 'pdf2jpg' has no attribute 'convert_pdf2jpg'

Any help would be appreciated as I am very new to Python.

我想您需要使用from pdf2jpg import pdf2jpg而不是import pdf2jpg as pdf2jpg这是两个不同的声明。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM