vb.net 在代码隐藏中创建的 Adobe 阅读器中打开 pdf 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13847904/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Open pdf file in Adobe reader created in code-behind
提问by Susan
How can I open a PDF document that I've created in code-behind in Adobe Reader?
如何打开我在 Adobe Reader 的代码隐藏中创建的 PDF 文档?
回答by Derek Tomes
If you want to open a pdf with the application that has a file association with it, do the following:
如果要使用具有文件关联的应用程序打开 pdf,请执行以下操作:
Process.Start("C:\foo\bar\mybook.pdf")
If you want to open a specific application instead (like Adobe Reader when you don't have a file association) do the same thing by passing the pdf file path as a command line parameter. You'll need to get the path to AcroRd32.exe from the registry because people may have different versions installed, or installed it to a different location.
如果你想打开一个特定的应用程序(比如当你没有文件关联时的 Adobe Reader)通过将 pdf 文件路径作为命令行参数传递来做同样的事情。您需要从注册表中获取 AcroRd32.exe 的路径,因为人们可能安装了不同的版本,或者将其安装到了不同的位置。
Process.Start("C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe", _
"C:\foo\bar\mybook.pdf")
The first option is generally better, because your software will respect whatever pdf reader your end-users have selected on their computer, or they may not have it installed at all.
第一个选项通常更好,因为您的软件将尊重您的最终用户在其计算机上选择的任何 pdf 阅读器,或者他们可能根本没有安装它。

