officefileapi-devexpress-dot-pdf-dot-pdfdocumentprocessor-dot-savedocument-x28-system-dot-io-dot-stream-x29.md
Saves the current document to the specified file stream.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Docs.v25.2.dll
NuGet Package : DevExpress.Document.Processor
public void SaveDocument(
Stream stream
)
Public Sub SaveDocument(
stream As Stream
)
| Name | Type | Description |
|---|---|---|
| stream | Stream |
A Stream value, specifying the location of the saved document.
|
When you dispose of an output stream that has not been detached, an attempt to apply further changes to a document may cause errors. If you want to close the stream when a document is saved, call the SaveDocument method overload with the detachStream parameter enabled.
If you load and save a document to the same stream, it may lead to unexpected results. Use the PdfDocumentProcessor.SaveDocument(Stream, PdfSaveOptions, Boolean) method overload for safer results.
Important
The PdfDocumentProcessor removes existing signatures from a document when it is saved. However, if you use PdfDocumentProcessor to apply a signature, it is retained.
The code sample below rotates document pages and saves the result:
using DevExpress.Pdf;
namespace PdfPageRotationExample
{
class Program
{
static void Main(string[] args)
{
using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor())
{
pdfDocumentProcessor.LoadDocument("..\\..\\docs\\TextRotate.pdf");
int angle = 0;
foreach (PdfPage page in pdfDocumentProcessor.Document.Pages) {
angle = (angle + 90) % 360;
page.Rotate = angle;
}
pdfDocumentProcessor.SaveDocument((new FileStream("Rotated.pdf", FileMode.Create, FileAccess.ReadWrite)));
}
}
}
}
Imports DevExpress.Pdf
Namespace PdfPageRotationExample
Friend Class Program
Shared Sub Main(ByVal args() As String)
Using pdfDocumentProcessor As New PdfDocumentProcessor()
pdfDocumentProcessor.LoadDocument("..\..\docs\TextRotate.pdf")
Dim angle As Integer = 0
For Each page As PdfPage In pdfDocumentProcessor.Document.Pages
angle = (angle + 90) Mod 360
page.Rotate = angle
Next page
pdfDocumentProcessor.SaveDocument((New FileStream("Rotated.pdf", FileMode.Create, FileAccess.ReadWrite)))
End Using
End Sub
End Class
End Namespace
The following code snippets (auto-collected from DevExpress Examples) contain references to the SaveDocument(Stream) 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.
office-file-api-in-web-api-app/CS/Controllers/PdfController.cs#L51
Stream result = new MemoryStream();
tempProcessor.SaveDocument(result);
result.Seek(0, SeekOrigin.Begin);
office-file-api-ai-implementation/CS/Controllers/TranslateController.cs#L139
MemoryStream result = new MemoryStream();
pdfDocumentProcessor.SaveDocument(result);
result.Seek(0, SeekOrigin.Begin);
See Also