Skip to content

Commit 40e8d15

Browse files
committed
Fix #2: failure caused by PDFViewer change
1 parent 566dfab commit 40e8d15

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

SyncfusionControl.cs

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
using System.IO;
1+
using System;
2+
using System.IO;
23
using System.Windows.Controls;
34
using System.Windows.Media;
5+
using System.Windows.Threading;
46
using QuickLook.Plugin.PDFViewer;
57
using Syncfusion;
68
using Syncfusion.OfficeChartToImageConverter;
@@ -89,22 +91,27 @@ private static Control OpenPowerpoint(string path)
8991

9092
var settings = new PresentationToPdfConverterSettings
9193
{
92-
OptimizeIdenticalImages = true, ShowHiddenSlides = true
94+
OptimizeIdenticalImages = true,
95+
ShowHiddenSlides = true
9396
};
9497

9598
var pdf = PresentationToPdfConverter.Convert(ppt, settings);
9699

97100
var viewer = new PdfViewerControl();
98-
using (var tempPdf = new MemoryStream())
99-
{
100-
pdf.Save(tempPdf);
101-
pdf.Close(true);
102101

103-
ppt.Close();
102+
var tempPdf = new MemoryStream();
103+
pdf.Save(tempPdf);
104+
pdf.Close(true);
105+
pdf.Dispose();
106+
ppt.Close();
107+
ppt.Dispose();
104108

109+
viewer.Dispatcher.BeginInvoke(new Action(() =>
110+
{
105111
viewer.LoadPdf(tempPdf);
106-
}
107-
112+
tempPdf.Dispose();
113+
}), DispatcherPriority.Loaded);
114+
108115
return viewer;
109116
}
110117
}

0 commit comments

Comments
 (0)