Jul-11-2024, 10:01 AM
I'm trying to create an application to automate a file creation process, but the first thing that I need to print out is a PDF file. I've tried to just use startfile() and import os, but I get the error:
Error:Traceback (most recent call last):
File "C:\Users\christopher.donnelly\PycharmProjects\HelloWorld\JobFileAutomation\JobFileAutomation.py", line 5, in <module>
os.startfile(filename, "print")
OSError: [WinError 1155] No application is associated with the specified file for this operation: 'Y:\\company orders\\C-Active Orders\\281794 Customer\\1-Sales\\281794 Customer OA.pdf'
and my code is only a few lines:import os filename = r'Y:\company orders\C-Active Orders\281794 Customer\1-Sales\281794 Customer OA.pdf' os.startfile(filename, "print")Why does the print option not work for a PDF file but it works for a text file? Does it need to be able to read the contents of the file to print it?