Class PdfSecurity
Represents Documentize.PdfSecurity plugin. Used to Encrypt, Decrypt and Sign PDF documents.
public static class PdfSecurityInheritance
Inherited Members
- object.GetType(),
- object.MemberwiseClone(),
- object.ToString(),
- object.Equals(object?),
- object.Equals(object?, object?),
- object.ReferenceEquals(object?, object?),
- object.GetHashCode()
Methods
Decrypt(DecryptOptions)
Decrypt PDF document.
public static ResultContainer Decrypt(DecryptOptions options)Parameters
optionsDecryptOptions: An options object containing instructions for the operation.
Returns
ResultContainer : An object containing the result of the operation.
Examples
The example demonstrates how to Decrypt PDF document.
// Create DecryptOptions object to set instructions
var options = new DecryptOptions("123456");
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfSecurity.Decrypt(options);Exceptions
If options not set.
Encrypt(EncryptOptions)
Encrypt PDF document.
public static ResultContainer Encrypt(EncryptOptions options)Parameters
optionsEncryptOptions: An options object containing instructions for the operation.
Returns
ResultContainer : An object containing the result of the operation.
Examples
The example demonstrates how to Encrypt PDF document.
// Create EncryptOptions object to set instructions
var options = new EncryptOptions("123456", "qwerty");
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfSecurity.Encrypt(options);Exceptions
If options not set.
Sign(SignOptions)
Sign PDF document by digital signature.
public static ResultContainer Sign(SignOptions options)Parameters
optionsSignOptions: An options object containing instructions for the operation.
Returns
ResultContainer : An object containing the result of the operation.
Examples
The example demonstrates how to Sign PDF document.
// Create SignOptions object to set instructions
var options = new SignOptions("path_to_your_pfx_file.pfx", "password_of_your_pfx_file");
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfSecurity.Sign(options);The example demonstrates how to Sign PDF document with Stream of PFX File.
using var pfxStream = File.OpenRead(@"path_to_your_pfx_file.pfx");
var options = new SignOptions(pfxStream, "password_of_your_pfx_file");
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfSecurity.Sign(options);The example demonstrates how to Sign PDF document with invisible signature.
var options = new SignOptions("path_to_your_pfx_file.pfx", "password_of_your_pfx_file");
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Configure invisible signature
signOptions.Visible = false;
// Perform the process
PdfSecurity.Sign(options);The example demonstrates how to Sign PDF document with extra options.
// Create SignOptions object to set instructions
var options = new SignOptions("path_to_your_pfx_file.pfx", "password_of_your_pfx_file");
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Optional parameters
options.Reason = "my Reason";
options.Contact = "my Contact";
options.Location = "my Location";
options.PageNumber = 3;
// Perform the process
PdfSecurity.Sign(options);The example demonstrates how Sign PDF document with Timestamp.
// Create SignOptions object to set instructions
var options = new SignOptions("path_to_your_pfx_file.pfx", "password_for_your_pfx_file");
options.TimestampOptions = new TimestampOptions("server_url");
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfSecurity.Sign(options);Exceptions
If options not set.
Namespace: Documentize Assembly: Documentize.dll