Print PDF using GhostScript

前端 未结 4 1590
一个人的身影
一个人的身影 2021-02-06 16:21

I am in need of your support on the following issue since its pulling me for a while. We have a small c# utility, which print given PDF using Gho

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-06 16:48

    Try the following command within Process.Start():

    gswin32c.exe -sDEVICE=mswinpr2 -dBATCH -dNOPAUSE -dNOPROMPT -dNoCancel -dPDFFitPage -sOutputFile="%printer%\\[printer_servername]\[printername]" "[filepath_to_pdf]"
    

    It should look like this in C#:

    string strCmdText = "gswin32c.exe -sDEVICE=mswinpr2 -dBATCH -dNOPAUSE -dNOPROMPT -dNoCancel -dPDFFitPage -sOutputFile=\"%printer%\\\\[printer_servername]\\[printername]\" \"[filepath_to_pdf]\"";
    System.Diagnostics.Process.Start("CMD.exe", strCmdText);
    

    This will place the specified PDF file into the print queue.

    Note- your gswin32c.exe must be in the same directory as your C# program. I haven't tested this code.

提交回复
热议问题