From 40e8d15b2315ae65b2d9bdd16e25a79752c65e97 Mon Sep 17 00:00:00 2001 From: Paddy Xu Date: Sun, 16 Sep 2018 14:41:40 +0300 Subject: [PATCH] Fix #2: failure caused by PDFViewer change --- SyncfusionControl.cs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/SyncfusionControl.cs b/SyncfusionControl.cs index 4fcdba1..b7186d8 100644 --- a/SyncfusionControl.cs +++ b/SyncfusionControl.cs @@ -1,6 +1,8 @@ -using System.IO; +using System; +using System.IO; using System.Windows.Controls; using System.Windows.Media; +using System.Windows.Threading; using QuickLook.Plugin.PDFViewer; using Syncfusion; using Syncfusion.OfficeChartToImageConverter; @@ -89,22 +91,27 @@ private static Control OpenPowerpoint(string path) var settings = new PresentationToPdfConverterSettings { - OptimizeIdenticalImages = true, ShowHiddenSlides = true + OptimizeIdenticalImages = true, + ShowHiddenSlides = true }; var pdf = PresentationToPdfConverter.Convert(ppt, settings); var viewer = new PdfViewerControl(); - using (var tempPdf = new MemoryStream()) - { - pdf.Save(tempPdf); - pdf.Close(true); - ppt.Close(); + var tempPdf = new MemoryStream(); + pdf.Save(tempPdf); + pdf.Close(true); + pdf.Dispose(); + ppt.Close(); + ppt.Dispose(); + viewer.Dispatcher.BeginInvoke(new Action(() => + { viewer.LoadPdf(tempPdf); - } - + tempPdf.Dispose(); + }), DispatcherPriority.Loaded); + return viewer; } }