Search code examples
pdfprintingghostscriptpostscript

How to use Ghostscript mswinpr2 to create postscript using print driver's settings


I found that using -sDEVICE="mswinpr2" and sOutputFile=%printer%printername works to print to the printer. But i would like to create a postscript using that installed (windows) printer's settings (duplex, tray input, output tray) from a pdf.

gswin64c.exe -dNOPAUSE -dBATCH -sDEVICE=mswinpr2 -sOutputfile="%printer%riso" "c:\temp\in.pdf"

What else would I add to output "out.ps"?

Also, I'm open to using ps2write, but I could not find where to use my installed printer's settings.


Solution

  • You don't want to use the mswinr2 device. The whole point of that device is that it will print to any Windows printer, but it does it in an ugly way; it renders the content of the input to a bitmap, then prints the bitmap.

    That often rsults in a huge spool file which prints very slowly. WHen you have no other option its a great way to print stuff to a specific printer, but for creating a PostScript file its going to produce a bit image which won't scale well (there will be artefacts in the image, jagged edges and such) and will be large and slow.

    Now, assuming that your printer is a PostScript printer, and for the purposes of getting the device-specific control parameters, you can change (or duplicate) your printer setup. If you change the port to FILE: then you can print to it and it will ask you for a filename to save as. Alternatively you can (usually) check the 'print to file' box. Doing either of these with the printer for which mswinpr2 is configured will produce an output PostScript file, if that is absolutely what you want.

    Once you have the settings you need, you should then use the ps2write device. Assuming you are using a recent version of Ghostscript the ps2write device understands the PSDocOptions and PSPageOptions switches, documented here. Using these you can insert arbitrary PostScript at the document and/or page level. You shold be abel to insert the settings discovered above using one of those controls.