[英]Diagnostics.Process doesn't open PDF file using adobe reader
I'm having a problem while trying to open a PDF file using Process.Start(). 我在尝试使用Process.Start()打开PDF文件时遇到问题。 The program runs the process as a background process but no adobe reader window show up.
该程序将该过程作为后台进程运行,但不显示任何adobe reader窗口。 A solution i found was to use chrome.exe, but my client want to open on adobe-reader, as it's the default windows program.
我找到的解决方案是使用chrome.exe,但我的客户端想在adobe-reader上打开,因为它是默认的windows程序。
(I have also trying without forcing "AcroRd32.exe" and passing the full path of "AcroRd32.exe". Same problem). (我也试过没有强制“AcroRd32.exe”并传递“AcroRd32.exe”的完整路径。同样的问题)。
Anyone solved this? 有人解决了吗?
My code: 我的代码:
var p = new Process
{
StartInfo = new ProcessStartInfo(@"AcroRd32.exe", @"D:\Tests\81803130000326__.pdf")
};
p.Start();
Background Processes: 后台流程:
I also have checked this question: Process.Start(/* path to pdf */) doesn't work with Adobe Reader on Windows 8 我也检查了这个问题: Process.Start(/ * pdf * /的路径)在Windows 8上不适用于Adobe Reader
EDIT INFO : Forgot to say i'm running Windows 10 with Adobe Reader DC 2018.009.20044 编辑信息 :忘了说我用Adobe Reader DC 2018.009.20044运行Windows 10
EDIT 2 : Found a "problem" of Adobe Reader DC. 编辑2 :发现Adobe Reader DC的“问题”。 It mantains a level of security that doesn't let me run it as administrator (don't ask me why).
它保持一定程度的安全性,不允许我以管理员身份运行它(不要问我原因)。 Check this link for more information: https://forums.adobe.com/thread/1955530
有关更多信息,请访问此链接: https : //forums.adobe.com/thread/1955530
Now I'll try to find a solution to run it without administrator privileges, or ask my client to uncheck the checkbox 现在我将尝试找到一个没有管理员权限运行它的解决方案,或者让我的客户取消选中该复选框
So, I've found a solution for my problem. 所以,我找到了解决问题的方法。 The Adobe Reader, since version 10.0, has a "Protected Mode" setting.
从10.0版开始,Adobe Reader具有“保护模式”设置。 I wrote a code to change that setting in the registry, so the user won't need to do that.
我编写了一个代码来更改注册表中的设置,因此用户不需要这样做。 Link: https://www.adobe.com/devnet-docs/acrobatetk/tools/AppSec/protectedmode.html
链接: https : //www.adobe.com/devnet-docs/acrobatetk/tools/AppSec/protectedmode.html
I hope it helps others in the future! 我希望将来能帮助别人!
Solution Code : 解决方案代码
var registroAdobe = Registry.LocalMachine.OpenSubKey(@"Software\Policies\Adobe\Acrobat Reader\DC\", true);
registroAdobe.SetValue("bProtectedMode", 0);
This works for Acrobat Reader DC. 这适用于Acrobat Reader DC。 You can run through "Software\\Policies\\Adobe\\" Products and Versions if you need it.
如果需要,您可以运行“Software \\ Policies \\ Adobe \\”产品和版本。
Actually, I found that this didn't work on my computer, but it led me to look deeper. 实际上,我发现这在我的电脑上不起作用,但它让我看起来更深。 I found my solution to be:
我发现我的解决方案是:
var regAdobe = Registry.CurrentUser.OpenSubKey(@"Software\Adobe\Acrobat Reader\DC\Privileged", true);
regAdobe.SetValue("bProtectedMode", 0);
Very similar, but ended up having to edit the user setting rather than the local machine's setting. 非常相似,但最终不得不编辑用户设置而不是本地机器的设置。
Cheers! 干杯!
您可以直接使用System.Diagnostics.Process.Start(“”)在各自的客户端系统上使用默认的pdfreader程序打开。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.