软件编程
位置:首页>> 软件编程>> C#编程>> Winform窗体中打开PDF文件的三种方式

Winform窗体中打开PDF文件的三种方式

作者:springsnow  发布时间:2023-05-15 19:46:52 

标签:C#,Winform,PDF,文件

1、使用Adobe PDF Reader控件。

从COM组件库中找到Adobe PDF Reader控件,添加到工具箱中。

Winform窗体中打开PDF文件的三种方式

从工具箱中拖入PDF Reader控件。

Winform窗体中打开PDF文件的三种方式

可以看到VS自动添加了AxInterop.AcroPDFLib.dll跟Interop.AcroPDFLib.dll这两个组件。

Winform窗体中打开PDF文件的三种方式

使用代码加载PDF文件:

//axAcroPDF1.src="D:\\aa.pdf";
axAcroPDF1.LoadFile("D:\\aa.pdf");

2、使用DevExpress控件中的pdfViewer控件

https://docs.devexpress.com/WindowsForms/9832/controls-and-libraries/pdf-viewer/examples/file-operations/how-to-load-a-pdf-document-from-a-file

this.pdfViewer1.LoadDocument(@"Report.pdf");

3、使用Spire.PdfViewer控件

https://www.e-iceblue.com/Introduce/free-pdf-viewer-net.html

免费版本:在查看和打印PDF文件时限于10页PDF。

从nuget下载Spire.PdfVie控件。

Winform窗体中打开PDF文件的三种方式

从工具箱拖入PdfViewer控件

Winform窗体中打开PDF文件的三种方式

自动引用了下面三个文件:

Winform窗体中打开PDF文件的三种方式

代码加载PDF文件

pdfViewer1.LoadFromFile("D:\\aa.pdf");

来源:https://www.cnblogs.com/springsnow/p/13305294.html

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com