Issue
I'd like to print a PDF file by Python, without opening any PDF viewer program (ex. adobe).
I have tried some code. It pop up the adobe program before printing.
first code
import win32print
import win32api
currentprinter = win32print.GetDefaultPrinter()
win32api.ShellExecute(0, "print", 'report.pdf', currentprinter, ".", 0)
second code
import os
os.startfile("report.pdf", "print")
Any code I have to rewrite or any recommend program to use instead of adobe?
Solution
download PDFtoPrinter.exe and move it into folder.
code it.
import subprocess def command_print(event = None): command = "{} {}".format('PDFtoPrinter.exe','report.pdf') subprocess.call(command,shell=True) command_print()
Answered By - Vittawat Laorungroj Answer Checked By - Clifford M. (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.