I have a function that convert the generated .docx file to .PDF and save it to the directory, after the save I want to print it to the printer.
I am having problem with the fileName, I am not able to read the directory.
pywintypes.error: (2, 'ShellExecute', 'The system cannot find the file specified.')
I am using win32api.ShellExecute()
for printing.
doc.save("./cr/generated_doc"+itemid1+".docx")
pythoncom.CoInitialize()
convert("./cr/generated_doc"+itemid1+".docx",
"./cr/pdf/label"+itemid1+".pdf")
printername = "Microsoft Print to PDF"
fileName = str(r"./cr/pdf/label"+itemid1+".pdf")
win32api.ShellExecute(0, "printto", filename, f'"{printername}"', ".", 0)
os.remove("./cr/generated_doc"+itemid1+".docx")
os.remove(fullnm)