签名

The Documentize PDF Security for .NET component allows users to digitally sign PDF documents. It offers a streamlined process for adding signatures, ensuring authenticity, and securing PDF content. The component supports both visible and invisible signatures and provides options to customize the signature’s position, reason, contact information, and more.

How to Sign PDF Documents

To sign a PDF document using a PFX file, follow these steps:

  1. Create ‘SignOptions’ with input PDF, output PDF, PFX file, and password.
  2. Adjust options if needed.
  3. Call ‘PdfSecurity.Sign’ with ‘options’.
1  
2// Create SignOptions object to set instructions  
3var options = new SignOptions("path_to_your_pdf_file.pdf", "path_to_result_pdf_file.pdf", "path_to_your_pfx_file.pfx", "password_of_your_pfx_file");  
4// Perform the process  
5PdfSecurity.Sign(options);  

How to Sign PDF with streams

  1. Create SignOptions with the streams and PFX password.
  2. Call PdfSecurity.Sign(options) to apply the signature.
1  
2// Prepare streams  
3using var pdfStreamInput = File.OpenRead(@"path_to_your_pdf_file.pdf");  
4using var pfxStreamInput = File.OpenRead(@"path_to_your_pfx_file.pfx");  
5using var pdfStreamOutput = new MemoryStream();  
6// Create SignOptions object to set instructions  
7var options = new SignOptions(pdfStreamInput, pdfStreamOutput, pfxStreamInput, "password_of_your_pfx_file");  
8// Perform the process  
9PdfSecurity.Sign(options);  

How to Sign PDF and set input and output parameters separately

1  
2// Create SignOptions object to set instructions  
3var options = new SignOptions("path_to_your_pfx_file.pfx", "password_of_your_pfx_file");  
4// Set input and output file paths  
5options.Input = new FileData("path_to_your_pdf_file.pdf");  
6options.Output = new FileData("path_to_result_pdf_file.pdf");  
7// Perform the process  
8PdfSecurity.Sign(options);  

How to apply invisible signatures

To add an invisible signature (one that secures the document without displaying the signature on the document), simply set the Visible property to false.

  1. Create an instance of SignOptions.
  2. Set Visible to false.
  3. Add input and output files.
  4. Call Sign to apply the invisible signature.
1  
2// Create SignOptions object to set instructions  
3var options = new SignOptions("path_to_your_pdf_file.pdf", "path_to_result_pdf_file.pdf", "path_to_your_pfx_file.pfx", "password_of_your_pfx_file");  
4// Configure invisible signature  
5options.Visible = false;  
6// Perform the process  
7PdfSecurity.Sign(options);  

How to use extra options for signature of PDF Documents

You can use extra options during adding signature to a PFX file like Reason, Contact, Location, PageNumber.

  1. Instantiate the SignOptions class with the PFX file path and password.
  2. Add the input PDF and the output file to the options.
  3. Set values for your options.
  4. Run the Sign method to apply the signature.
 1  
 2// Create SignOptions object to set instructions  
 3var options = new SignOptions("path_to_your_pdf_file.pdf", "path_to_result_pdf_file.pdf","path_to_your_pfx_file.pfx", "password_of_your_pfx_file");  
 4// Optional parameters  
 5options.Reason = "my Reason";  
 6options.Contact = "my Contact";  
 7options.Location = "my Location";  
 8options.PageNumber = 3;  
 9// Perform the process  
10PdfSecurity.Sign(options);  

How to Sign PDF file in the shortest possible style

1  
2PdfSecurity.Sign(new SignOptions("path_to_your_pdf_file.pdf", "path_to_result_pdf_file.pdf", "path_to_your_pfx_file.pfx", "password_of_your_pfx_file"));  

How to add a Timestamp to PDF

To add a secure timestamp to a PDF document, follow these steps:

  1. Create an instances of TimestampOptions and SignOptions to configure the timestamping process.
  2. Add the input PDF file using the AddInput method.
  3. Set the output file path using AddOutput method.
  4. Execute the timestamping using the Sign method.
1  
2// Create SignOptions object to set Timestamp  
3var options = new SignOptions(new TimestampOptions("server_url"));  
4// Set input and output file paths  
5options.Input = new FileData("path_to_your_pdf_file.pdf");  
6options.Output = new FileData("path_to_result_pdf_file.pdf");  
7// Perform the process  
8PdfSecurity.Sign(options);  

How to Use Custom Authentication with Timestamp Server

You can provide basic authentication credentials when connecting to the timestamp server. This allows you to authenticate with servers that require a username and password.

1  
2// Configure the timestamping options with authentication  
3var tOptions = new TimestampOptions("timestamp_server_url", "username:password");  

Key Features:

  • Digitally Sign PDF Documents: Secure your documents with visible or invisible digital signatures.
  • PFX Support: Sign PDF files using a PFX certificate.
  • Customizable Options: Configure signature settings like reason, location, and contact details.
  • Visible and Invisible Signatures: Choose whether the signature is visible on the document.
  • Customizable Timestamp Servers: Use custom timestamp server URLs and authentication credentials.
 中文