I'm adding a document viewer to my WPF project and all seems perfect. But when I try to open another xps file, the documentviewer places some [?] signs in my document.
Here's my code :
if (xps != null)
{
xps.Close();
xps = null;
}
docViewer.Document = null;
Microsoft.Office.Interop.Excel.Application eApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook eWb;
Microsoft.Office.Interop.Excel.Worksheet eWs;
eApp.Visible = false;
eWb = eApp.Workbooks.Open(gekozenProductBestand, false,false, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, true, false, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
eWs = (Microsoft.Office.Interop.Excel.Worksheet)eWb.Worksheets[1];
eWs.PageSetup.Orientation = Microsoft.Office.Interop.Excel.XlPageOrientation.xlLandscape;
eWb.ExportAsFixedFormat(XlFixedFormatType.xlTypeXPS, System.IO.Path.GetTempPath() + "producten", XlFixedFormatQuality.xlQualityStandard, true, true, Type.Missing, Type.Missing, false, Type.Missing);
eApp.DisplayAlerts = false;
eApp.Quit();
xps = new XpsDocument(System.IO.Path.GetTempPath() + "producten.xps", System.IO.FileAccess.Read);
docViewer.Document = xps.GetFixedDocumentSequence();
docViewer.FitToWidth();
eApp.DisplayAlerts = false;
eWs = null;
eWb = null;
eApp.Quit();
eApp = null;
GC.Collect();
And finally an image to make myself clear : http://img818.imageshack.us/img818/7043/knipselq.png