0

While sending attachments to print, How can I pass tray number to the printer? I am using below code to print attachments:

    void PrintProcess(string FullFilePath)
    {         
            System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(FullFilePath);
            info.Arguments = "\"" + cmbPrinter.Text + "\"";
            info.CreateNoWindow = true;
            info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            info.UseShellExecute = true;
            info.Verb = "PrintTo";

            //System.Diagnostics.Process.Start(info);

            Process p = new Process();

            p.Refresh();
            p.StartInfo = info;
            p.Start();
            if (_pdfC == 0)
                _Pid = p.Id;
            _pdfC++;
            p.WaitForInputIdle();

            info = null;
        }

Giving Input Values like

Sagar Pudi
  • 4,634
  • 3
  • 32
  • 51
Sai
  • 1
  • Possible duplicate of [How to pass multiples arguments in processStartInfo?](https://stackoverflow.com/questions/15061854/how-to-pass-multiples-arguments-in-processstartinfo) – BrunoMartinsPro Apr 05 '18 at 08:41
  • You should create a custom verb, check the MS doc https://msdn.microsoft.com/en-us/library/windows/desktop/cc144175(v=vs.85).aspx or the .net printing classes https://msdn.microsoft.com/en-us/library/system.drawing.printing.printersettings(v=vs.110).aspx – Cleptus Apr 05 '18 at 08:43
  • 1
    What happens when the shell's `PrintTo` verb is invoked isn't standardized. That the first argument is the name of the printer is standard, but beyond that there are no arguments for passing model-specific details like the tray number of your printer, if it has more than one tray. That's a vendor-specific property that can't be passed by standard means; you need to capture the settings and reapply them. [See here](https://www.codeproject.com/articles/488737/storing-and-recalling-printer-settings-in-csharp-n). – Jeroen Mostert Apr 05 '18 at 08:49
  • There is an article on MSDN demonstrating PaperSource. might give some thoughts .. https://msdn.microsoft.com/en-us/library/system.drawing.printing.pagesettings.papersource.aspx – Sagar Pudi Apr 05 '18 at 09:14

0 Answers0