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();
 }
Manos Nikolaidis
  • 21,608
  • 12
  • 74
  • 82

1 Answers1

1

You need to set the printer defaults the way you want them, you can't (in the vanilla version) have gsprint set collate.

Alternatively, of course, you can modify gsprint to accept a new command line parameter and use that to control the printer collate.

NB AutoRotatePages and PDFSETTINGS have no effect except on the pdfwrite device (so not with any physical printer) and PreserveOverprint has no effect on any device. PDFFitPage only works if the input is a PDF file.

KenS
  • 30,202
  • 3
  • 34
  • 51
  • Can you give me sample how to pass that argument? – Gokuldas.Palapatta Oct 17 '15 at 18:40
  • You will need to modify the gsprint C sources to accept a new argument, and use its value to set the appropriate member in the print structure. Examine the existing source code, it already does this for other arguments. – KenS Oct 18 '15 at 07:53
  • I have the same problem, I tried to set the collation in default printer settings in my windows printer but it doesn't work when I send the -dNumCopies argument with a value greater then 1 . – Tobia Jun 22 '18 at 13:48