PdfViewer.LoadDocument(Stream) Method
Loads a PDF document from the specified stream.
Namespace: DevExpress.XtraPdfViewer
Assembly: DevExpress.XtraPdfViewer.v20.2.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
stream | Stream | A Stream class descendant. |
Remarks
The input stream is not closed until a document is opened. Set the PdfViewer.DetachStreamAfterLoadComplete property to true before specifying the document source to close the stream when a document is opened.
Examples
The following example illustrates how to load a document into the PDF Viewer from a stream at runtime.
To accomplish this task: create a FileStream object with the specified file path to open the existing file, and call one of the PdfViewer.LoadDocument overloaded method with this stream object passed as a parameter.
NOTE
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-load-a-pdf-document-from-a-stream-t270045
using System.IO;
using System.Windows.Forms;
namespace LoadDocumentFromStream {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
// Load a document from the stream.
FileStream stream = new FileStream("..\\..\\Demo.pdf", FileMode.Open);
pdfViewer1.LoadDocument(stream);
}
}
}