(Jun-11-2022, 05:56 AM)DPaul Wrote: Seems that it still is a 'file not found' problem.
It worked when I hard coded the path and filename.
(Jun-11-2022, 05:56 AM)DPaul Wrote: Maybe try this:
import os path_to_pdf = os.path.join('c:\data' , 'pdfdir', 'pdfsubdir','mypdf.pdf') Now your file is always found by using the variable path_to_pdf
Thanks; I couldn't get that to work, however it caused me to investigate what that "r" in
pdfs = r"provide path to pdf file"was used for. Found a good article at https://www.codespeedy.com/how-does-carr...in-python/ , then realised I didn't need that "r" at all. As I needed the PDF filename to be an argument, it now works okay as
from pdf2image import convert_from_path import sys # Print total number of arguments print ('Total number of arguments:', format(len(sys.argv))) # Print all arguments print ('Argument List:', str(sys.argv)) # Print arguments one by one print ('First argument:', str(sys.argv[0])) print ('Second argument:', str(sys.argv[1])) filename = sys.argv[1] pdfs = filename pages = convert_from_path(pdfs, 350) i = 1 for page in pages: image_name = "Page_" + str(i) + ".jpg" page.save(image_name, "JPEG") i = i+1