打开.NET中的PDF [英] Opening a pdf in .NET

查看:211
本文介绍了打开.NET中的PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在应用程序,我们正在努力,我们正在努力实现帮助。我们有帮助,PDF文档,并为目前它已被认为是可以接受的,当用户点击帮助按钮,它只是打开的PDF。该应用程序是一个桌面应用程序,PDF文件需要在本地计算机上以某种方式和安装安装到被包括在内。

In the application we are working on we are trying to implement Help. We have a help pdf document and for the moment it has been deemed acceptable that when users click the help button it just opens the pdf. The application is a desktop app and the pdf file needs to be included in the install somehow and installed on the local machine.

我基本上需要两件事情:

I essentially need two things:

  1. 我怎么会这个PDF添加到 应用程序以便它可用 在客户机上安装后? 我可以把它的资源 该项目的,要不然我可以把 它的应用程序文件夹 客户端安装程序安装程序。

  1. How would I add this pdf to the application so that it is available on the client machine after install? I can either put it in the resources of the project, or else I could put it in the Application Folder of the client setup installer.

我将如何打开这个PDF文件? 我可以通过只需打开该PDF 启动默认的PDF查看器 该文件,或者我可以使用 System.WinForms.WebBrowser工具 显示它。但是,如果我选择 第二个选项,我不确定如何 访问存储在该文件 资源或找到它的安装 文件夹。

How would I open this pdf? I can either open this pdf by just launching the default pdf viewer for the file, or I can use the System.WinForms.WebBrowser tool to display it. However if I choose the second option, I am unsure of how to access the file stored in the resources or find it in the install folder.

如果你能请我提供code要做到这一点(无论是在VB.Net或C#.NET),这将是巨大的。

If you could please provide me with the code to do this (either in VB.Net or C#.Net) that would be great.

推荐答案

这是我们如何做到了:

把所有的帮助文件夹%ApplicationFolder%/帮助。因此,您的PDF将有路径%ApplicationFolder%/帮助/手册.pdf 。您可以创建一个帮助文件夹,并把你的PDF文件在你csproject,整个整个连接到 csproject ,并将其设置为复制始终。通过这种方式,你可以确保在PDF文件复制到帮助文件夹总是最新的。

Put all the help folders in %ApplicationFolder%/Help. So, your pdf will have the path %ApplicationFolder%/Help/Manual.pdf. You can create a Help folder and put in your pdfs at your csproject, and attach the whole whole to the csproject, and set it to copy always. In this way you can make sure that the pdfs you copy to the Help folder are always the latest.

和复制从debug文件夹中的一切(当然减去PDB文件)添加到您的部署文件夹。

And copy everything ( minus the pdb files, of course) from your debug folder to your deploy folder.

然后,使用 System.Diagnostics.Process.Start(pdfPath)启动帮助文件,点击帮助按钮时。这里是你如何能得到pdfPath:

Then, use System.Diagnostics.Process.Start(pdfPath) to start the help file when the help button is clicked. Here's how you can get the pdfPath:

这里的code片断:

public void Help_Click(object sender, System.EventArgs e)
{
           var appDir = Path.GetDirectoryName(Application.StartupPath);
            var helDir = Path.Combine(appDir, "Help");
            var pdfPath = Path.Combine(helDir, "Manual.pdf");
System.Diagnostics.Process.Start(pdfPath);
}

您可以在调试模式下进行测试。只要preSS F5(记得到PDF文件复制到debug文件夹中),你可以得到它

You can test this in debug mode. Just press F5 ( remember to copy the pdf file to the debug folder) and you can get it

这篇关于打开.NET中的PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆