Skip to main content

PdfDocumentProcessor.SaveDocument(Stream) Method

Saves the current document to the specified file stream.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Docs.v23.2.dll

NuGet Package: DevExpress.Document.Processor

Declaration

public void SaveDocument(
    Stream stream
)

Parameters

Name Type Description
stream Stream

A Stream value, specifying the location of the saved document.

Remarks

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:

View Example

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