0

I have the below code. As per my knowledge it is converting and saving as pdf. Can anyone explain this code?

Process cnp = new Process();
cnp.StartInfo.FileName = "AcroRd64.exe";
cnp.StartInfo.Arguments = "/n /t c:/test.jpg Microsoft Office Document Image   Writer";

Updates:

I created a sample console application to trigger print and it is not working

class Program
{
    static void Main(string[] args)
    {
        try
        {
            Process p = new Process();

            p.StartInfo.FileName = @"C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe";
            p.StartInfo.Verb = "Print";
            p.StartInfo.Arguments = "/n /t c:/test.png " + "Microsoft Office Document Image Writer";
            p.StartInfo.CreateNoWindow = false;
            p.StartInfo.UseShellExecute = true;
            p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;

        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
        Console.ReadKey();
    }
}

1 Answers1

0

Process is used to start and stop processes on your system.

Seems pretty clear that your code attempts to start a process "AcroRd64.exe", which I would guess is the pdf-reader Adobe Acrobat Reader. Argumens are arguments to the process, so basically, this is the equivalent of writing the following in command line:

AcroRd64.exe /n /t c:/test.jpg Microsoft Office Document Image   Writer

There's a little more info on this under this other SO question.

Your code might doesn't work because the single argument Microsoft Office Document Image Writer contains whitespace. Try:

 cnp.StartInfo.Arguments = 
     "AcroRd64.exe /n /t c:/test.jpg \"Microsoft Office Document Image Writer\"";
Community
  • 1
  • 1
Kjartan
  • 18,591
  • 15
  • 71
  • 96
  • This test.jpg is not opening, Do the code converts to TIFF before process? –  Jan 29 '15 at 07:12