Back to Devexpress

PdfDocumentProcessor.SaveDocument(String) Method

officefileapi-devexpress-dot-pdf-dot-pdfdocumentprocessor-dot-savedocument-x28-system-dot-string-x29.md

latest7.2 KB
Original Source

PdfDocumentProcessor.SaveDocument(String) Method

SECURITY-RELATED CONSIDERATIONS

Using file paths sourced from untrusted input may expose unauthorized files or allow unintended file access. Always validate and normalize all external paths to prevent path manipulation.

Saves the current document to the specified file path.

Namespace : DevExpress.Pdf

Assembly : DevExpress.Docs.v25.2.dll

NuGet Package : DevExpress.Document.Processor

Declaration

csharp
public void SaveDocument(
    string path
)
vb
Public Sub SaveDocument(
    path As String
)

Parameters

NameTypeDescription
pathString

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

|

Remarks

The PDF Document API component locks a file while a document is saved (since the SaveDocument method uses the detachStream parameter set to false ). To unlock the file, call another overloaded SaveDocument method with the detachStream parameter enabled.

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

csharp
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("..\\..\\docs\\Rotated.pdf");
        }
     }
  }
}
vb
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("..\..\docs\Rotated.pdf")
          End Using
      End Sub
  End Class
End Namespace

The following code snippets (auto-collected from DevExpress Examples) contain references to the SaveDocument(String) 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.

pdf-document-api-xmp-example/CS/XmpMetadataExamples/Program.cs#L54

csharp
// Save the result:
    pdfDocumentProcessor.SaveDocument("Invoice_Upd.pdf");
}

pdf-document-api-flatten-interactive-form/CS/FlattenInteractiveForm/Program.cs#L17

csharp
// Save a document with the flattened form field.
processor.SaveDocument("..\\..\\..\\Result1.pdf");

pdf-document-api-remove-interactive-form-fields/CS/RemoveInteractiveForm/Program.cs#L16

csharp
// Save the modified document.
processor.SaveDocument("..\\..\\..\\Result1.pdf");

how-to-custom-draw-in-pdf-viewer/CS/PDF_Viewer/Form1.cs#L57

csharp
}
    processor.SaveDocument(saveFileDialog.FileName);
}

pdf-document-api-delete-pages-from-document/CS/PdfDeletePageExample/Program.cs#L23

csharp
}
    pdfDocumentProcessor.SaveDocument("..\\..\\..\\docs\\Deleted.pdf");
}

pdf-document-api-xmp-example/VB/XmpMetadataExamples/Program.vb#L43

vb
' Save the result:
    pdfDocumentProcessor.SaveDocument("Invoice_Upd.pdf")
End Using

pdf-document-api-flatten-interactive-form/VB/FlattenInteractiveForm/Program.vb#L16

vb
' Show a message if the form field was not found in a document.
    processor.SaveDocument("..\..\..\Result1.pdf")
Else

pdf-document-api-remove-interactive-form-fields/VB/RemoveInteractiveForm/Program.vb#L15

vb
' Save the modified document.
    processor.SaveDocument("..\..\..\Result1.pdf")
Else

how-to-custom-draw-in-pdf-viewer/VB/PDF_Viewer/Form1.vb#L52

vb
processor.SaveDocument(saveFileDialog.FileName)
End Using

pdf-document-api-delete-pages-from-document/VB/PdfDeletePageExample/Program.vb#L19

vb
Next
    pdfDocumentProcessor.SaveDocument("..\..\..\docs\Deleted.pdf")
End Using

See Also

PdfDocumentProcessor Class

PdfDocumentProcessor Members

DevExpress.Pdf Namespace