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);