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?
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.
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.
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();
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.
I don't see your full code, but I solved similar issue by setting
ProcessStartInfo.UseShellExecute
to true.
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();
来源:https://stackoverflow.com/questions/23778366/process-start-path-to-pdf-doesnt-work-with-adobe-reader-on-windows-8