|
@@ -2,6 +2,7 @@
|
|
|
using ComPDFKitViewer.PdfViewer;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Diagnostics;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
@@ -131,29 +132,33 @@ namespace compdfkit_tools.PDFControl
|
|
|
thumbnailItemList.Clear();
|
|
|
for (int i = 0; i < pdfView.Document.PageCount; i++)
|
|
|
{
|
|
|
-
|
|
|
Size pageSize = pdfView.Document.GetPageSize(i);
|
|
|
|
|
|
- int imageWidth = pageSize.Width > pageSize.Height ? thumbnailWidth * 2 : (int)(pageSize.Width / pageSize.Height * thumbnailWidth * 2);
|
|
|
- int imageHeight = pageSize.Height > pageSize.Width ? thumbnailWidth * 2 : (int)(pageSize.Height / pageSize.Width * thumbnailWidth * 2);
|
|
|
+ int imageWidth = 0;
|
|
|
+ int imageHeight = 0;
|
|
|
|
|
|
- Image img = new Image()
|
|
|
+ if(pageSize.Width>0 && pageSize.Height>0)
|
|
|
{
|
|
|
- Margin = new Thickness(0, 0, 5, 0),
|
|
|
-
|
|
|
- Width = imageWidth,
|
|
|
- Height = imageHeight,
|
|
|
- Stretch = Stretch.Uniform,
|
|
|
- };
|
|
|
-
|
|
|
- ThumbnailItem addItem = new ThumbnailItem();
|
|
|
- addItem.ImageHeight = imageHeight;
|
|
|
- addItem.ImageWidth = imageWidth;
|
|
|
- addItem.ThumbnailHeight = thumbnailWidth;
|
|
|
- addItem.ThumbnailWidth = thumbnailWidth;
|
|
|
- addItem.PageIndex = i;
|
|
|
- addItem.ImageData = img;
|
|
|
- thumbnailItemList.Add(addItem);
|
|
|
+ imageWidth = pageSize.Width > pageSize.Height ? thumbnailWidth * 2 : (int)(pageSize.Width / pageSize.Height * thumbnailWidth * 2);
|
|
|
+ imageHeight = pageSize.Height > pageSize.Width ? thumbnailWidth * 2 : (int)(pageSize.Height / pageSize.Width * thumbnailWidth * 2);
|
|
|
+ Image img = new Image()
|
|
|
+ {
|
|
|
+ Margin = new Thickness(0, 0, 5, 0),
|
|
|
+
|
|
|
+ Width = imageWidth,
|
|
|
+ Height = imageHeight,
|
|
|
+ Stretch = Stretch.Uniform,
|
|
|
+ };
|
|
|
+
|
|
|
+ ThumbnailItem addItem = new ThumbnailItem();
|
|
|
+ addItem.ImageHeight = imageHeight;
|
|
|
+ addItem.ImageWidth = imageWidth;
|
|
|
+ addItem.ThumbnailHeight = thumbnailWidth;
|
|
|
+ addItem.ThumbnailWidth = thumbnailWidth;
|
|
|
+ addItem.PageIndex = i;
|
|
|
+ addItem.ImageData = img;
|
|
|
+ thumbnailItemList.Add(addItem);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
ThumbControl.SetThumbResult(thumbnailItemList);
|