C# 实现帮助/PDF文档显示

Moonpdf库引用:

  • 将MoonPdfLib.dll、libmupdf.dll、MouseKeyboardActivityMonitor.dll放置在工程目录下;
  • 在项目工程中引用MoonPdfLib.dll;
  • 在.xmal文件中添加相关引用:
xmlns:mpp="clr-namespace:MoonPdfLib;assembly=MoonPdfLib"

添加控件:

<Border Background="#d3d3d3" Grid.Row="1">
            <mpp:MoonPdfPanel x:Name="moonPdfPanel" Background="LightGray" ViewType="SinglePage" PageRowDisplay="ContinuousPageRows" PageMargin="0,2,4,2" AllowDrop="True"/>
</Border>

加载PDF文件:

//电脑中pdf的路径
string filePath = AppDomain.CurrentDomain.BaseDirectory + "系统说明书.pdf";
moonPdfPanel.OpenFile(filePath);
moonPdfPanel.Zoom(1.0);
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
C#中,你可以使用Microsoft.Office.Interop.PowerPoint库来实现PPT文档PDF文档。具体实现步骤如下: 1. 首先,你需要安装Microsoft PowerPoint软件,并且在Visual Studio中添加对Microsoft.Office.Interop.PowerPoint库的引用。 2. 在代码中创建一个PowerPoint.Application对象,并打开PPT文档。 ``` PowerPoint.Application pptApplication = new PowerPoint.Application(); PowerPoint.Presentation pptPresentation = pptApplication.Presentations.Open(@"C:\path\to\ppt\file.pptx"); ``` 3. 使用SaveAs方法将PPT文档转换为PDF文档。 ``` pptPresentation.SaveAs(@"C:\path\to\pdf\file.pdf", PowerPoint.PpSaveAsFileType.ppSaveAsPDF); ``` 4. 关闭PPT文档和PowerPoint.Application对象。 ``` pptPresentation.Close(); pptApplication.Quit(); ``` 完整的代码示例: ``` using System; using PowerPoint = Microsoft.Office.Interop.PowerPoint; namespace PPTtoPDF { class Program { static void Main(string[] args) { // 创建PowerPoint.Application对象 PowerPoint.Application pptApplication = new PowerPoint.Application(); // 打开PPT文档 PowerPoint.Presentation pptPresentation = pptApplication.Presentations.Open(@"C:\path\to\ppt\file.pptx"); // 将PPT文档转换为PDF文档 pptPresentation.SaveAs(@"C:\path\to\pdf\file.pdf", PowerPoint.PpSaveAsFileType.ppSaveAsPDF); // 关闭PPT文档和PowerPoint.Application对象 pptPresentation.Close(); pptApplication.Quit(); } } } ``` 注意:在运行代码之前,请确保Microsoft PowerPoint已经安装在你的计算机上,并且在Visual Studio中添加了对Microsoft.Office.Interop.PowerPoint库的引用。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值