Class PdfSecurity
Representa o plugin Documentize.PdfSecurity. Usado para Criptografar, Descriptografar e Assinar documentos PDF.
public static class PdfSecurityHerança
Membros herdados
- object.GetType(),
- object.MemberwiseClone(),
- object.ToString(),
- object.Equals(object?),
- object.Equals(object?, object?),
- object.ReferenceEquals(object?, object?),
- object.GetHashCode()
Métodos
Decrypt(DecryptOptions)
Descriptografa um documento PDF.
public static ResultContainer Decrypt(DecryptOptions options)Parâmetros
optionsDecryptOptions: Um objeto de opções contendo instruções para a operação.
Retorno
ResultContainer : Um objeto contendo o resultado da operação.
Exemplos
O exemplo demonstra como Descriptografar um documento PDF.
// Create DecryptOptions object to set instructions
var options = new DecryptOptions("123456");
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Perform the process
PdfSecurity.Decrypt(options);Exceções
Se as opções não estiverem definidas.
Encrypt(EncryptOptions)
Criptografa um documento PDF.
public static ResultContainer Encrypt(EncryptOptions options)Parâmetros
optionsEncryptOptions: Um objeto de opções contendo instruções para a operação.
Retorno
ResultContainer : Um objeto contendo o resultado da operação.
Exemplos
O exemplo demonstra como Criptografar um documento PDF.
// Create EncryptOptions object to set instructions
var options = new EncryptOptions("123456", "qwerty");
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Perform the process
PdfSecurity.Encrypt(options);Exceções
Se as opções não estiverem definidas.
Sign(SignOptions)
Assina um documento PDF com assinatura digital.
public static ResultContainer Sign(SignOptions options)Parâmetros
optionsSignOptions: Um objeto de opções contendo instruções para a operação.
Retorno
ResultContainer : Um objeto contendo o resultado da operação.
Exemplos
O exemplo demonstra como Assinar um documento PDF.
// 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 FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Perform the process
PdfSecurity.Sign(options);O exemplo demonstra como Assinar um documento PDF com Stream do arquivo PFX.
using var pfxStream = File.OpenRead(@"path_to_your_pfx_file.pfx");
var options = new SignOptions(pfxStream, "password_of_your_pfx_file");
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Perform the process
PdfSecurity.Sign(options);O exemplo demonstra como Assinar um documento PDF com assinatura invisível.
var options = new SignOptions("path_to_your_pfx_file.pfx", "password_of_your_pfx_file");
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Configure invisible signature
signOptions.Visible = false;
// Perform the process
PdfSecurity.Sign(options);O exemplo demonstra como Assinar um documento PDF com opções extras.
// 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 FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("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);O exemplo demonstra como Assinar um documento PDF com 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 FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Perform the process
PdfSecurity.Sign(options);Exceções
Se as opções não estiverem definidas.
Namespace: Documentize Assembly: Documentize.dll