Print PDF using GhostScript in LANDSCAPE

寵の児 提交于 2019-12-25 04:33:41

问题


I am printing a PDF file as follows:

using (GhostscriptProcessor processor = new GhostscriptProcessor())
{
    List<string> switches = new List<string>();
    switches.Add("-empty");
    switches.Add("-dPrinted");
    switches.Add("-dBATCH");
    switches.Add("-dNOPAUSE");
    switches.Add("-dNOSAFER");
    switches.Add("-dNumCopies=1");
    switches.Add("-sDEVICE=mswinpr2");
    switches.Add("-sOutputFile=%printer%" + printerName);
    switches.Add("-f");
    switches.Add(inputFile);
    processor.StartProcessing(switches.ToArray(), null);
}

It works beautifully but I have a problem there. I can't (and really tried) print any PDF file in landscape. I tries with Orientation, with resize, changing the system preferences of the printer. Anything I do is for nothing because it is always printed in portrait.

Any ideas?


回答1:


What problem are you trying to solve ? If you are trying to get the printer to print on landscape media, and that isn't its default, then its not going to work the mswinpr2 device can't change the tray selection.




回答2:


Try something like:

using (GhostscriptProcessor processor = new GhostscriptProcessor())
{
    List<string> switches = new List<string>();
    switches.Add("-empty");
    switches.Add("-dPrinted");
    switches.Add("-dBATCH");
    switches.Add("-dNOPAUSE");
    switches.Add("-dNOSAFER");
    switches.Add("-dNumCopies=1");
    switches.Add("-sDEVICE=mswinpr2");
    switches.Add("-sOutputFile=%printer%" + printerName);
    switches.Add("-c");
    switches.Add("<</Orientation 3>> setpagedevice");
    switches.Add("-f");
    switches.Add(inputFile);
    processor.StartProcessing(switches.ToArray(), null);
}


来源:https://stackoverflow.com/questions/31158896/print-pdf-using-ghostscript-in-landscape

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!