Back to Devexpress

RichEditDocumentServer.SaveDocument(Stream, DocumentFormat) Method

officefileapi-devexpress-dot-xtrarichedit-dot-richeditdocumentserver-dot-savedocument-x28-system-dot-io-dot-stream-devexpress-dot-xtrarichedit-dot-documentformat-x29.md

latest6.2 KB
Original Source

RichEditDocumentServer.SaveDocument(Stream, DocumentFormat) Method

Saves the document to a stream, specifying the document’s format.

Namespace : DevExpress.XtraRichEdit

Assembly : DevExpress.RichEdit.v25.2.Core.dll

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
public virtual void SaveDocument(
    Stream stream,
    DocumentFormat documentFormat
)
vb
Public Overridable Sub SaveDocument(
    stream As Stream,
    documentFormat As DocumentFormat
)

Parameters

NameTypeDescription
streamStream

The stream to output the document to.

| | documentFormat | DocumentFormat |

One of the DocumentFormat enumeration values.

|

Remarks

When the specified document format requires that a certain type of content should be saved as external objects, as is the case for HTML format, the proper use of the SaveDocument becomes more complex. Handle the RichEditDocumentServer.BeforeExport event to specify exporter options, such as the IExporterOptions.TargetUri and the HtmlDocumentExporterOptions.

Note

The SaveDocument method call does not automatically change the RichEditDocumentServer.Modified property value.

The following code snippets (auto-collected from DevExpress Examples) contain references to the SaveDocument(Stream, DocumentFormat) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

word-document-api-automatic-document-conversion-on-web-server/CS/Program.cs#L97

csharp
server.SaveDocument(fsOut, destFormat);
Console.WriteLine(outFileName + " file is converted.");

office-file-api-dockerize-application/CS/DocumentConversionWebApi/Controllers/ConvertFileController.cs#L51

csharp
wordProcessor.Options.Export.Html.EmbedImages = true;
wordProcessor.SaveDocument(resultStream, DevExpress.XtraRichEdit.DocumentFormat.Html);
resultStream.Seek(0, SeekOrigin.Begin);

word-document-api-examples/CS/CodeExamples/ExportActions.cs#L129

csharp
{
    wordProcessor.SaveDocument(htmlFileStream, DocumentFormat.Html);
}

word-document-api-use-multiple-data-sources-for-mail-merge/CS/MailMergeSample/Default.aspx.cs#L62

csharp
documentServer.SaveDocument(result, documentFormat);

office-file-api-in-web-api-app/CS/BusinessObjects/Helpers.cs#L35

csharp
if (encryptionSettings == null)
    server.SaveDocument(resultStream, documentFormat);
else

word-document-api-automatic-document-conversion-on-web-server/VB/Program.vb#L86

vb
server.SaveDocument(fsOut, destFormat)
Console.WriteLine(outFileName & " file is converted.")

word-document-api-examples/VB/CodeExamples/ExportActions.vb#L114

vb
Using htmlFileStream As System.IO.FileStream = New System.IO.FileStream(filePath, System.IO.FileMode.Create)
    wordProcessor.SaveDocument(htmlFileStream, DevExpress.XtraRichEdit.DocumentFormat.Html)
End Using

word-document-api-use-multiple-data-sources-for-mail-merge/VB/MailMergeSample/Default.aspx.vb#L50

vb
documentServer.Document.AppendDocumentContent(part2, documentFormat)
documentServer.SaveDocument(result, documentFormat)
Return result

Implements

SaveDocument(Stream, DocumentFormat)

See Also

IUriProvider

RichEditDocumentServer Class

RichEditDocumentServer Members

DevExpress.XtraRichEdit Namespace