View pdf in wpf

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Viewer for .NET (v1.x)  /  Display Thread

DynamicPDF Viewer for .NET (v1.x) Forum

 Jun 16 2014 5:44 AM
i need to show pdf as preview using ceTe.DynamicPDF.Viewer.PdfViewer in wpf from stream object .
How can i made preview?
 Jun 16 2014 10:44 AM
Posted by a ceTe Software moderator
Hello,

Yes, you can use the DynamicPDF Viewer for .NET control in WPF to open the PDFs dynamically. Below are the steps to add the Viewer for .NET control to WPF. You will need to use the PdfDocument class which takes PDF file path, PDF contents in the form of stream or byte array and create object of PdfDocument class. Then use this PdfDocument object in Open method  of Viewer object to display the PDF in the Viewer control. You can also refer to the documentation on opening PDF here.

a)Reference the DynamicPDF Viewer for .NET DLL in your WPF application.
b)Add reference to the System.Windows.Forms and WindowsFormsIntegration assemblies.
c)Open the MainWindow.xaml in designer mode.
d)Add a WindowsFormHost WPF control to the  MainWindow.
e)Initialize  the Viewer control  in MainWindow class constructor.
f)Add the Viewer control to the WindowsFormHost container and then open the PDF dynamically in Viewer using Open method. Below is code sample for it.

            FileStream streamObj = new FileStream(@"C:\Temp\MyDocument.pdf", FileMode.Open);
            PdfDocument pdf = new PdfDocument(streamObj);
            this.windowsFormsHost1.Child = viewerObj;
            viewerObj.Open(pdf);

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 8:48 AM.