浏览代码

Added ImageUtils.GetPDFThumbnail

frogsoftware 1 年之前
父节点
当前提交
8c08b3c92e
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      inabox.wpf/ImageUtils.cs

+ 9 - 0
inabox.wpf/ImageUtils.cs

@@ -803,6 +803,15 @@ namespace InABox.WPF
             return null;
         }
 
+        public static byte[] GetPDFThumbnail(byte[] pdfData, int width, int height)
+        {
+            PdfLoadedDocument loadeddoc = new PdfLoadedDocument(pdfData);
+            Bitmap image = loadeddoc.ExportAsImage(0, new SizeF(width, height), true);
+            MemoryStream stream = new MemoryStream();
+            image.Save(stream, ImageFormat.Jpeg);
+            return stream.ToArray();
+        }
+
         public static List<byte[]> RenderPDFToImages(byte[] pdfData, ImageEncoding encoding = ImageEncoding.JPEG)
         {
             var rendered = new List<byte[]>();