这里主要用到mupdf库
库是由C写的
mupdf有一个.NET的移植版本mupdf-converter
项目地址: https://github.com/dwaleke/mupdf-converter
mupdf-converter可以将PDF转换成Bitmap,也可以直接转换成WPF使用的BitmapSource。
使用方法如下:
1 int width = 0; 2 int height = 0; 3 int rotation = 0; 4 int page = 1; 5 int dpi = 96; 6 MuPDFLib.RenderType RenderType = RenderType.RGB; 7 bool rotateAuto = false; 8 string file = @"test.pdf"; 9 string password = ""; 10 11 MuPDFLib.MuPDF pdfDoc = new MuPDFLib.MuPDF(file, password); 12 13 pdfDoc.Page = page; 14 Bitmap bitmap = pdfDoc.GetBitmap(width, height, dpi, dpi, rotation, RenderType, 15 rotateAuto, false, 0); 16 17 var bitmapSource = pdfDoc.GetBitmapSource(width, height, dpi, dpi, rotation, RenderType,rotateAuto, false, 0); 18 pdfDoc.Dispose();