0

I am having big problems trying to print a PDF file in Windows using Ghostscript. The 'in Windows' argument comes from the fact that I am trying to use MS Windows default driver for this '-sDEVICE=mswinpr2'. I need all windows printers/drivers support. Also I can not use the PDF to images then to print job kind of solution. I cant use the gswin64c.exe file also, and I need that the job is done without any popups (no form of any kind). All I can do is just to send some parameters to gsdll32.dll and it to create a print job.

I am using C# wrapper https://github.com/mephraim/ghostscriptsharp/tree/master

I am sending the following parameters: "-dBATCH -dNOPAUSE -dNOPROMPT -dDEVICEWIDTHPOINTS=612 -dDEVICEHEIGHTPOINTS=792 -dFIXEDMEDIA -dPDFFitPage -sDEVICE=mswinpr2 -dQUIET -sOutputFile=\"%printer%Epson Stylus Pro 4900\" D:\1.pdf"

And every time the printer selection dialog keeps popping up. I understand that the order the parameters are in matters .... because I changed it and it had different results.

Actual Question: What parameters do I have to send to GhostScript dll so that I can print a PDF file using the default MS Windows printing driver.

Alex
  • 11
  • 2

3 Answers3

0

Have you tried this using the command line version of GS instead of the DLL or C# thingy ? I'd suggest you concentrate on getting that to work first.

What is the name of the printer (as it appears in Windows) ?

What version of Ghostscript are you using ?

Try using the command line without '-dBATCH', '-dNOPAUSE', '-dNOPROMPT', '-dQUIET'. that way if Ghostscript tries to tell you something you won't just ignore it or miss it.

If the command line works then; I see you've escaped the " characters, but not the '%', you might want to escape those, or double them up. Depending how this wrapper of yours works they might be getting read as format specifiers.

KenS
  • 30,202
  • 3
  • 34
  • 51
0

The parameters used in the command line have been verified first in the command line version gswin64c.exe (64 bit operation system) and they work fine.

I am using GS version 9.10 (latest version).

I've tried different combinations of parameters, with or without some of them ... same result ... -100 exit code (general fault with no specification of the error that caused it).

It doesn't seem to be a problem with that % character... I'll try some more things.

Thanks Ken for the help

Alex
  • 11
  • 2
0

As far as the printer dialog popup is concerned, if you replace "mswinpr2" with the a compatible device name such as ljet4, the prompts would go away. My guess is that your computer must be having more than one printer installed and hence windows prompts for you to choose one from the list.

Kiran Xyz
  • 63
  • 1
  • 6