How to: Load a PDF Document from a Stream
This example shows how to load a document from the Stream using the DocumentViewerControl.DocumentSource property. The stream is obtained from the assembly resources:
Note that when you load a document, the input stream will not be closed before the control finishes using a document (PdfViewerControl.DetachStreamOnLoadComplete is set to false by default). This allows the PDF Viewer to render a large PDF quickly.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-load-a-pdf-document-from-a-stream-t263193.
using System.IO;
using System.Reflection;
using System.Windows;
namespace LoadPDFDocument {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
Stream stream = GetResourceStream("LoadPDFDocument.Demo.pdf");
Viewer.DocumentSource = stream;
}
static Stream GetResourceStream(string resourceName) {
return Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
}
}
}