Class PdfSecurity

Informação

Representa o plugin Documentize.PdfSecurity. Usado para Criptografar, Descriptografar e Assinar documentos PDF.

public static class PdfSecurity

Herança

objectPdfSecurity

Membros herdados

Métodos

Decrypt(DecryptOptions)

Descriptografa um documento PDF.

public static ResultContainer Decrypt(DecryptOptions options)

Parâmetros

  • options DecryptOptions: 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

ArgumentException

Se as opções não estiverem definidas.

Encrypt(EncryptOptions)

Criptografa um documento PDF.

public static ResultContainer Encrypt(EncryptOptions options)

Parâmetros

  • options EncryptOptions: 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

ArgumentException

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

  • options SignOptions: 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

ArgumentException

Se as opções não estiverem definidas.

Namespace: Documentize Assembly: Documentize.dll

 Português