Class PdfSecurity
Representa el plugin Documentize.PdfSecurity. Usado para Encriptar, Desencriptar y Firmar documentos PDF.
public static class PdfSecurityHerencia
Miembros heredados
- object.GetType(),
- object.MemberwiseClone(),
- object.ToString(),
- object.Equals(object?),
- object.Equals(object?, object?),
- object.ReferenceEquals(object?, object?),
- object.GetHashCode()
Métodos
Decrypt(DecryptOptions)
Desencripta un documento PDF.
public static ResultContainer Decrypt(DecryptOptions options)Parámetros
optionsDecryptOptions: Un objeto de opciones que contiene las instrucciones para la operación.
Retorna
ResultContainer : Un objeto que contiene el resultado de la operación.
Ejemplos
El ejemplo muestra cómo Desencriptar un 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);Excepciones
Si no se establecen las opciones.
Encrypt(EncryptOptions)
Encripta un documento PDF.
public static ResultContainer Encrypt(EncryptOptions options)Parámetros
optionsEncryptOptions: Un objeto de opciones que contiene las instrucciones para la operación.
Retorna
ResultContainer : Un objeto que contiene el resultado de la operación.
Ejemplos
El ejemplo muestra cómo Encriptar un 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);Excepciones
Si no se establecen las opciones.
Sign(SignOptions)
Firma un documento PDF mediante firma digital.
public static ResultContainer Sign(SignOptions options)Parámetros
optionsSignOptions: Un objeto de opciones que contiene las instrucciones para la operación.
Retorna
ResultContainer : Un objeto que contiene el resultado de la operación.
Ejemplos
El ejemplo muestra cómo Firmar un 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);El ejemplo muestra cómo Firmar un documento PDF con un Stream del archivo 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);El ejemplo muestra cómo Firmar un documento PDF con firma invisible.
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);El ejemplo muestra cómo Firmar un documento PDF con opciones adicionales.
// 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);El ejemplo muestra cómo Firmar un documento PDF con 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);Excepciones
Si no se establecen las opciones.
Namespace: Documentize Assembly: Documentize.dll