1
public void PrinterThread(string printerName, string fileName, bool portrait,string Copies)
{
     string gsArguments, gsLocation;
     ProcessStartInfo gsProcessInfo;
     Process gsProcess;

     if (portrait)
     {
         //gsArguments = string.Format("-dAutoRotatePages=/All -dNOPAUSE -dBATCH -sPAPERSIZE=a4  -dFIXEDMEDIA -dPDFFitPage -dEmbedAllFonts=true -dSubsetFonts=true  -dPDFSETTINGS=/prepress -dNOPLATFONTS  -noquery -dNumCopies=" + Copies + " -all  -colour -printer \"{0}\" \"{1}\"", printerName, fileName);
         gsArguments = string.Format("-dAutoRotatePages=/ALL -dNOPAUSE -dBATCH -dPreserveOverSettings=/false -dNumCopies=" + Copies + " -printer  \"{0}\" \"{1}\"", printerName, fileName);
        // gsArguments = string.Format("-ghostscript \"{0}\" -copies=2 -all -printer \"{0}\" \"{1}\"", printerName, fileName);
       //  gsArguments = string.Format("-noquery -portrait -printer \"{0}\" \"{1}\"",
             //printerName, fileName);
         gsLocation = @"C:\Users\gokul.das\Desktop\Silent_Print\Silent_Print\bin\Debug\gsview\gsprint.exe";

     }
     else
     {
         gsArguments = string.Format("-dAutoRotatePages=/All -dNOPAUSE -dBATCH -sPAPERSIZE=a4 -dFIXEDMEDIA -dPDFFitPage -dEmbedAllFonts=true -dSubsetFonts=true -dPDFSETTINGS=/prepress -dNOPLATFONTS -sFONTPATH=\"C:\\Program Files\\gs\\gs9.10\\fonts\" -noquery -dNumCopies==" + Copies + "  -all -colour -printer \"{0}\" \"{1}\"", printerName, fileName);
         //gsArguments = string.Format("-noquery -landscape -printer \"{0}\" \"{1}\"",
         //     printerName, fileName);
         gsLocation = @"C:\Users\gokul.das\Desktop\Silent_Print\Silent_Print\bin\Debug\gsview\gsprint.exe";
     }
     gsProcessInfo = new ProcessStartInfo();
     gsProcessInfo.WindowStyle = ProcessWindowStyle.Hidden;
     gsProcessInfo.FileName = gsLocation;
     gsProcessInfo.Arguments = gsArguments;
     gsProcess = Process.Start(gsProcessInfo);
     //gsProcess.WaitForExit();
 }
4

1 回答 1

1

您需要按照您想要的方式设置打印机默认值,您不能(在香草版本中)有 gsprint 设置整理。

或者,当然,您可以修改 gsprint 以接受新的命令行参数并使用它来控制打印机分页。

NB AutoRotatePages 和 PDFSETTINGS 对 pdfwrite 设备(因此不适用于任何物理打印机)没有影响,而 PreserveOverprint 对任何设备都没有影响。PDFFitPage 仅在输入为 PDF 文件时才有效。

于 2015-10-17T14:06:57.633 回答