My task is to print PDF file using Windows OS and Python. So when I print through my HP printer I get the exact copy of that PDF, but with the gray color background.
I generate PDF using PyFPDF
library. It works fine. Here is the output of the PDF file. If I print through Adobe Acrobat Reader, there is no gray color background. But when I print using ghostscript
, it's comes with gray color background.
import subprocess
import win32print
generated_pdf_name = 'some_pdf_name.pdf'
current_printer = win32print.GetDefaultPrinter()
query = f'{os.path.join("GHOSTSCRIPT", "bin", "gswin64c.exe")} -dPrinted -dBATCH -dNOPAUSE -dFitPage -q -dNumCopies=1 -dNoCancel -sDEVICE=mswinpr2 -dDeviceGrayToK=false -sOutputFile="%printer%{current_printer}" "{os.path.join(generated_pdf_name)}"'
subprocess.call(query, shell=True)
Here I used MS Windows printers, so -sDEVICE=mswinpr2
. I also tried with gsprint
. But it doesn't show images in my PDF file. So that's I moved into ghostscript
. It printed all the content of this PDF file, but only problem is the gray color background.
Take a look Gray color printed output, I need plain output without gray background. Did I miss anything above?