有没有办法在 Winforms 工具中查看 PDF 文件?我看到一些解决方案,比如将 PDF 文件转换为图像并在图片框中显示它们。但是,我想问的是是否可以作为 PDF 查看文件。 Adobe 或 Microsoft 是否有支持此功能的工具?
有没有办法在 Winforms 工具中查看 PDF 文件?我看到一些解决方案,比如将 PDF 文件转换为图像并在图片框中显示它们。但是,我想问的是是否可以作为 PDF 查看文件。 Adobe 或 Microsoft 是否有支持此功能的工具?
您可以使用 System.Diagnostics.Process.Start 或者通过Interop使用 WIN32 ShellExecute 函数 打开PDF文件,以使用默认的查看器:
System.Diagnostics.Process.Start("SOMEAPP.EXE","Path/SomeFile.Ext");
[System.Runtime.InteropServices.DllImport("shell32. dll")]
private static extern long ShellExecute(Int32 hWnd, string lpOperation,
string lpFile, string lpParameters,
string lpDirectory, long nShowCmd);
另一种方法是在你的表单中放置一个 WebBrowser 控件,然后使用Navigate方法打开 PDF 文件:
ThewebBrowserControl.Navigate(@"c:\the_file.pdf");
我认为最简单的方法是使用Adobe PDF阅读器COM组件
希望这可以帮到您
Web浏览器控件可能是有效的。这里有一篇文章提供了更多信息:http://ryanfarley.com/blog/archive/2004/12/23/1330.aspx
此外,这里还有一些开源C# PDF项目:http://csharp-source.net/open-source/pdf-libraries
http://www.youtube.com/watch?v=a59LvC6BOuk
请使用上面的链接。private void btnopen_Click(object sender, EventArgs e){
OpenFileDialog openFileDialog1 = new OpenFileDialog();
if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK){
axAcroPDF1.src = openFileDialog1.FileName;
}
}