pankajr141 / pdf2jpg

Utility to convert PDF into JPG files
51 stars 21 forks source link

[WinError 2] The system cannot find the file specified #5

Closed g444ran closed 4 years ago

g444ran commented 5 years ago

Executing the below: from pdf2jpg import pdf2jpg inputpath = r'D:\sample.pdf'

outputpath = r'D:\image.jpg'

To convert single page

result = pdf2jpg.convert_pdf2jpg(inputpath, outputpath, dpi=300, pages="ALL")

print(result)

Error I get: [WinError 2] The system cannot find the file specified False

jesse-jenkins commented 5 years ago

i was able to get it to work loading like this where rootdir is in the format 'C://some_pdfs_folder//'

for root, subFolders, files in os.walk(rootdir):
for file in files: theFile = os.path.join(root,file) fileName, fileExtension = os.path.splitext(theFile) if fileExtension.lower() in ('.pdf'):
try: File = pdf2jpg.convert_pdf2jpg(theFile,pdf_output,pages="ALL")

here theFile is the rootdir path+somefile.pdf and pdf_output is some other folder below rootdir

this routine works for a lot of pdf producer types, but fails on certain types not closed/finalized properly throwing the common java memory exception.

nadachaabani1 commented 5 years ago

Try to check if you have java in your system, because the system is based on jar manipulation.

pankajr141 commented 4 years ago

seems like duplicate of https://github.com/pankajr141/pdf2jpg/issues/7 Hence closing