11

I'm able to create PDFs in my C#/WPF application and run them with the following:

Process.Start(_pathToPDFFile);

This works with Adobe Acrobat, but not with Adobe Reader. When Adobe Reader is installed, Process.Start() does nothing unless the Reader process is already running in the Task Manager.

How can I get Adobe Reader to show the PDF when I attempt to start a PDF?

DaveDev
  • 41,155
  • 72
  • 223
  • 385
  • Does it sneakily open it in the "TIFKAM screen"? Can you get the path to the Adobe Reader program from the registry and use that explicitly in `Process.Start`? [Adobe Reader Command Line Reference Q on Stack Overflow](http://stackoverflow.com/questions/619158/adobe-reader-command-line-reference). – Andrew Morton May 21 '14 at 09:03
  • Exactly the same problem here on a build PC. Did you find a solution, by any chance? – Borislav Ivanov Sep 04 '17 at 06:46
  • Nope, never did. I've long since left that company. – DaveDev Sep 04 '17 at 23:46

6 Answers6

3

In our case, the problem was only reproducible when starting the application from Visual Studio - starting the .exe directly works as expected.

After some debugging, it turned out that Visual Studio was set to always run as administrator, which causes the issue. Turning this off (which is hard enough itself) fixes the problem.

Still not sure why this happens, though.

Borislav Ivanov
  • 4,684
  • 3
  • 31
  • 55
2

Maybe try something like this? I tried you code on Windows 8 with Adobe Reader 11 and it seems to work fine for me. Maybe something else is wrong on the machine in question?

var process = new Process();
process.StartInfo = new ProcessStartInfo(@"Path to your PDF.pdf");
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = true;
process.Start();
Mo Patel
  • 2,321
  • 4
  • 22
  • 37
  • I searched the www for 2 hours. Nothing worked for me, to simply open a pdf File.... Until I found this! TY SIR, TY soooo much! – MrOrhan Mar 31 '21 at 06:05
0

Here is how I do, there may be a way to recover the exact path to AcroRd32.exe from Registry although :

String pathToAcroRd32 = Environment.GetEnvironmentVariable("ProgramFiles") + ((Environment.Is64BitOperatingSystem) ? @" (x86)\" : @"\") + "Adobe\Reader 11.0\Reader\AcroRd32.exe";
ProcessStartInfo adobeInfo = new ProcessStartInfo(pathToAcroRd32, _pathToPDFFile);
Process.Start(adobeInfo);

Depending also on the version of Acrobat Reader to launch (if different from Adobe Reader 11.0) you may have to change the path.

Hybris95
  • 2,286
  • 2
  • 16
  • 33
  • The example here only shows that you should pass the path to acrobat reader explicitly to your Process.Start() by making a ProcessStartInfo object. Then there is work to do on how this path should be recovered or built. The following example shows a way by building the path, but this can only work if you know the computers the app will be executed on. – Hybris95 May 21 '14 at 09:16
0

First, you must check if Adobe Reader is the default program for pdf files. You can check it in Control Panel -> Programs -> Default Programs -> Set Associations.

If Adobe Reader is the default PDF program, your code should work on Windows 8, actually in most version of Windows.

If Adobe Reader is not the default PDF program, you need must get path to AcroRd32.exe. This post should help you. Then just execute code in Hybris95's answer.

Community
  • 1
  • 1
qxg
  • 6,955
  • 1
  • 28
  • 36
0

I don't see your full code, but I solved similar issue by setting ProcessStartInfo.UseShellExecute to true.

vvvlad
  • 378
  • 2
  • 13
0

I still have this problem, can't make the AcroRd32.exe to open, just stays there in the task manager. A possible solution is choosing chrome.exe to start the PDF.

Like this:

var p = new Process
{
    StartInfo = new ProcessStartInfo(@"chrome.exe",  path)
    {
        WindowStyle = ProcessWindowStyle.Maximized
    }
};

p.Start();
daniele3004
  • 13,072
  • 12
  • 67
  • 75
Wesley
  • 61
  • 1
  • 4
  • If you have a NEW question, please ask it by clicking the [Ask Question](http://stackoverflow.com/questions/ask) button. If you have sufficient reputation, [you may upvote](http://stackoverflow.com/privileges/vote-up) the question. Alternatively, "star" it as a favorite and you will be notified of any new answers. – Mgetz Nov 27 '17 at 12:47