PdfDocumentProcessor.SaveDocument(String, PdfSaveOptions) Method
Saves the current PDF document to the specified file path with encryption and sign settings.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Docs.v24.2.dll
NuGet Package: DevExpress.Document.Processor
#Declaration
public void SaveDocument(
string path,
PdfSaveOptions options
)
#Parameters
Name | Type | Description |
---|---|---|
path | String | A String, specifying the path to the directory to which the PDF document should be saved. |
options | Pdf |
A Pdf |
#Remarks
The PDF Document API component locks a file while a document is saved (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 Pdf
#Example
This example shows how a PDF document can be protected using both the owner and user passwords.
Refer to the following topic for more information: Document Protection
using DevExpress.Pdf;
namespace PDFPasswordProtection
{
class Program
{
static void Main(string[] args)
{
using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor()) {
// Load a PDF document.
pdfDocumentProcessor.LoadDocument("..\\..\\Demo.pdf");
// Specify printing, data extraction, modification, and interactivity permissions.
PdfEncryptionOptions encryptionOptions = new PdfEncryptionOptions();
encryptionOptions.PrintingPermissions = PdfDocumentPrintingPermissions.Allowed;
encryptionOptions.DataExtractionPermissions = PdfDocumentDataExtractionPermissions.NotAllowed;
encryptionOptions.ModificationPermissions = PdfDocumentModificationPermissions.DocumentAssembling;
encryptionOptions.InteractivityPermissions = PdfDocumentInteractivityPermissions.Allowed;
// Specify the owner and user passwords for the document.
encryptionOptions.OwnerPasswordString = "OwnerPassword";
encryptionOptions.UserPasswordString = "UserPassword";
// Specify the 256-bit AES encryption algorithm.
encryptionOptions.Algorithm = PdfEncryptionAlgorithm.AES256;
// Save the protected document with encryption settings.
pdfDocumentProcessor.SaveDocument("..\\..\\ProtectedDocument.pdf", new PdfSaveOptions() { EncryptionOptions = encryptionOptions });
}
}
}
}
#Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the SaveDocument(String, PdfSaveOptions) 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.