从显示Winform中的PDF文件 [英] Displaying a pdf file from Winform

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

问题描述

我只是建立在C#中(Windows窗体)一个简单的计算器

I'm just creating a simple calculator in C# (windows form)

我创建了一个用户帮助,这是一个PDF文件,我想要什么是,如果用户点击在WinForm的帮助按钮来显示PDF文件。如果假设则Adobe Reader预先安装在用户的计算机上....


如何打开按钮单击PDF文件中的winform?

I've created a "User Help" which is a pdf file, what I want is to display that pdf file if the user clicks on the "Help" button in the WinForm. If assumed that Adobe reader is pre-installed on the user's machine....

How to open the pdf file on button click in winForm?

我不打算提供有关用户硬盘本PDF文件。这意味着我必须把这个PDF嵌入到计算器(WinForm的),并有将其显示在按钮上点击。


请指导我与在winform显示嵌入文件的最佳做法。

I don't plan to provide this pdf file on hard disk of user. Which means that I have to embed this pdf into the calculator (winForm) and have to display it on the button click.

Kindly guide me with the best practise for displaying an embedded file in winForm.

推荐答案

我把它放在我的程序文件夹中,增添我的开始菜单文件夹中的链接,以允许直接访问(不启动我的工具),只是在一些单击事件 System.Diagnostics.Process.Start(@\Manual.pdf。);

I would put it on within my program folder, add a link within my Start Menu folder to allow a direct access (without starting my tool) and just at on some click event System.Diagnostics.Process.Start(@".\Manual.pdf");

好了,现在我们来到一个完全新的问题:如何嵌入一个文件在我的应用程序并启动它?

Ok, now we come to a completely new question: How to embed a file in my application and start it?

有关这个问题你已经在这里找到几个答案,但这里是短版:

For this question you'll find already several answers here, but here is the short version:


  1. 右键点击您的项目,并选择添加 - 现有项目

  2. 选择您的文件(不要双击它

    • 点击小箭头旁边的添加按钮,然后选择添加链接

  1. Right click your project and select Add - Existing Item
  2. Select your file (don't double click it)
    • Click the little arrow next to the Add button and select Add As Link

通过这些步骤,您引用您的文件以往任何时候都存在于您的结构中的位置。如果你喜欢你的PDF文件的副本将在您的项目中被放入一个子文件夹中的资源,只跳过点一和二在上面的列表中。

With these steps you reference your file where ever it exists within your structure. If you like that a copy of your pdf file will be put into a subfolder Resources within your project, just skip the points one and two in the above list.

要获得您的PDF现已开通,你必须写下来字节[]到磁盘(可能与 Path.GetTempFileName()),并使用Adobe Reader启动它。 (不要忘记删除使用后的文件)

To get your pdf now opened, you'll have to write the byte[] down to disk (maybe with Path.GetTempFileName()) and start it with Adobe Reader. (Don't forget to delete the file after usage)

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

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