Skip to main content
A newer version of this page is available. .

PdfViewer.SaveDocument(Stream) Method

Saves the current PDF to the specified stream.

Namespace: DevExpress.XtraPdfViewer

Assembly: DevExpress.XtraPdfViewer.v22.1.dll

NuGet Package: DevExpress.Win.PdfViewer

Declaration

public bool SaveDocument(
    Stream stream
)

Parameters

Name Type Description
stream Stream

A System.IO.Stream, specifying the document address.

Returns

Type Description
Boolean

true, if the document is saved successfully; false, if the document saving operation is cancelled by the user.

Remarks

If the PdfViewer.DetachStreamAfterLoadComplete property is set to false (default mode), the input stream should not be closed until a document is opened.

If you want to close the stream when a document is opened, set the PdfViewer.DetachStreamAfterLoadComplete property to true.

The following example illustrates how to load a document into the PDF Viewer from a stream at runtime.

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

The PDF Viewer expects that the input stream is not modified or closed before the component finishes using a document. Set true as the PdfViewer.DetachStreamAfterLoadComplete property value to force the PDF Viewer to complete all input operations after loading a document. Set this property to false to lock files by the input stream (i.e., make it impossible to edit or delete the document until it is opened in the PDF Viewer) and render large PDF files faster.

View Example

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);
        }
    }
}
See Also