PDF Security

加密

使用 Documentize 的 .NET 工具加密 PDF 文件,以保护敏感信息。

解密

使用 Documentize 的 .NET 工具解密您的 PDF 文件,以打开文档。

签名

使用 Documentize 的 .NET 工具对 PDF 文件进行数字签名——轻松实现安全性、真实性和合规性。

Sanitize

Sanitize hidden data from PDF with Documentize's .NET tools, ensuring that sensitive or unnecessary information such as metadata, attachments, annotations, JavaScripts, forms, layers, search index, or private content is removed or transformed.

PDF Security 的子部分

加密

Documentize PDF Security for .NET 是一个强大的工具,旨在通过提供加密、解密和签名功能来增强 PDF 文档的安全性。它确保您的敏感信息保持机密,并防止未授权访问。

如何加密 PDF

要加密 PDF 文档,请按照以下步骤操作:

  1. 创建 EncryptOptions 实例,并设置所需的用户密码和所有者密码。
  2. 使用 AddInput 方法添加输入 PDF 文件
  3. 使用 AddOutput 方法添加输出 PDF 文件
  4. 使用 PdfSecurity 类的 Encrypt 方法执行加密
1// Create EncryptOptions object to set instructions
2var options = new EncryptOptions("123456", "qwerty");
3// Add input file path
4options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
5// Set output file path
6options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
7// Perform the process
8PdfSecurity.Encrypt(options);

关键特性:

  • 加密 PDF 文档:通过添加用户密码和所有者密码来保护您的 PDF 文件。
  • 自动化:将加密和解密集成到您的 .NET 应用程序中,实现自动化工作流。
  • 合规性:确保您的文档符合行业文档安全标准。

解密

Documentize PDF 安全 for .NET 是一款强大的工具,旨在通过提供加密、解密和签名功能来提升 PDF 文档的安全性。它确保您的敏感信息保持机密,免受未授权访问的侵扰。

如何解密 PDF

要解密 PDF 文档,请按照以下步骤操作:

  1. 创建 DecryptionOptions 实例,并提供必要的密码。
  2. 使用 AddInput 方法添加输入 PDF 文件
  3. 使用 AddOutput 方法添加输出 PDF 文件
  4. 调用 PdfSecurity 类的 Decrypt 方法执行解密。
1// Create DecryptOptions object to set instructions
2var options = new DecryptOptions("123456");
3// Add input file path
4options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
5// Set output file path
6options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
7// Perform the process
8PdfSecurity.Decrypt(options);

关键特性:

  • 解密 PDF 文档:在需要时移除 PDF 的加密。
  • 自动化:将加密和解密集成到您的 .NET 应用程序中,实现自动化工作流。
  • 合规性:确保您的文档符合行业文档安全标准。

签名

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. Instantiate the SignOptions class with the PFX file path and password.
  2. Add the input PDF and the output file to the options.
  3. Run the Sign method to apply the signature.
1// Create SignOptions object to set instructions
2var options = new SignOptions("path_to_your_pfx_file.pfx", "password_of_your_pfx_file");
3// Add input file path
4options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
5// Set output file path
6options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
7// Perform the process
8PdfSecurity.Sign(options);

How to Use Stream for PFX File

You can also sign a PDF using a PFX certificate provided as a stream instead of a file path. This allows more flexible handling of certificate storage.

1using var pfxStream = File.OpenRead(@"path_to_your_pfx_file.pfx");
2var options = new SignOptions(pfxStream, "password_of_your_pfx_file");
3options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
4options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
5// Perform the process
6PdfSecurity.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.
1var options = new SignOptions("path_to_your_pfx_file.pfx", "password_of_your_pfx_file");
2options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
3options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
4// Configure invisible signature
5signOptions.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// Create SignOptions object to set instructions
 2var options = new SignOptions("path_to_your_pfx_file.pfx", "password_of_your_pfx_file");
 3// Add input file path
 4options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
 5// Set output file path
 6options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
 7// Optional parameters
 8options.Reason = "my Reason";
 9options.Contact = "my Contact";
10options.Location = "my Location";
11options.PageNumber = 3;
12// Perform the process
13PdfSecurity.Sign(options);

How to Add a Timestamp to PDF

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

  1. Create an instance of AddTimestampOptions to configure the timestamping process.
  2. Add the input PDF file using the AddInput method.
  3. Set the output file path using AddOutput.
  4. Execute the timestamping using the Sign method.
1// Create SignOptions object to set instructions
2var options = new SignOptions("path_to_your_pfx_file.pfx", "password_for_your_pfx_file");
3options.TimestampOptions = new TimestampOptions("server_url");
4// Add input file path
5options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
6// Set output file path
7options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
8// Perform the process
9PdfSecurity.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// Configure the timestamping options with authentication
2options.TimestampOptions = 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.

Sanitize

Documentize PDF Security for .NET 组件允许用户对 PDF 文档进行清理。它提供了简化的流程,以删除元数据、附件、批注、JavaScript、表单、图层、搜索索引或私有内容等敏感或不必要的信息。组件提供了自定义要删除信息的选项。

清除信息

  • 元数据
  • 附件
  • 批注
  • Java 脚本
  • 表单
  • 图层
  • 搜索索引

如何清理 PDF 文档

要清理 PDF 文件,请按照以下步骤操作:

  1. 使用输入文件路径和输出文件路径实例化 SanitizeOptions 类。
  2. 调用 Sanitize 方法执行清理。
1// Create SanitizeOptions object to set input and output files
2var options = new SanitizeOptions("path_to_your_pdf_file.pdf", "path_to_result_pdf_file.pdf");
3// Perform the process
4PdfSecurity.Sanitize(options);

如何使用流进行输入和输出

也可以使用提供为流的 PDF 文档进行清理,而不是指定文件路径。

1// Prepare input and output streams
2using var inputStream = File.OpenRead("path_to_your_pdf_file.pdf");
3using var outputStream = new MemoryStream();
4// Create SanitizeOptions object to set input and output streams
5var options = new SanitizeOptions(inputStream, outputStream);
6// Perform the process
7PdfSecurity.Sanitize(options);

如何从文件清理到流

可以设置不同类型的输入和输出数据。

1// Prepare output stream
2using var outputStream = new MemoryStream();
3// Create SanitizeOptions object to set input file and output stream
4var options = new SanitizeOptions("path_to_your_pdf_file.pdf", outputStream);
5// Perform the process
6PdfSecurity.Sanitize(options);

如何通过属性将文件清理到流

可以使用属性设置不同类型的输入和输出数据。

 1// Prepare output stream
 2using var outputStream = new MemoryStream();
 3// Create SanitizeOptions object
 4var options = new SanitizeOptions();
 5//Set Input file
 6options.Input = new FileData("path_to_your_pdf_file.pdf");
 7//Set Output stream
 8options.Output = new StreamData(outputStream);
 9// Perform the process
10PdfSecurity.Sanitize(options);

如何在不删除元数据的情况下进行清理

只需将 RemoveMetadata 属性设为 false

1// Create SanitizeOptions object to set input and output files
2var options = new SanitizeOptions("path_to_your_pdf_file.pdf", "path_to_result_pdf_file.pdf");
3options.RemoveMetadata = false;
4// Perform the process
5PdfSecurity.Sanitize(options);

如何在不删除附件的情况下进行清理

只需将 RemoveAttachments 属性设为 false

1// Create SanitizeOptions object to set input and output files
2var options = new SanitizeOptions("path_to_your_pdf_file.pdf", "path_to_result_pdf_file.pdf");
3options.RemoveAttachments = false;
4// Perform the process
5PdfSecurity.Sanitize(options);

如何在将所有页面转换为图像并设置结果 DPI 的情况下进行清理

示例演示如何在清理 PDF 时将所有页面转换为图像并设置结果 DPI。将 ConvertPagesToImages 属性设为 true,如有需要更改 ImageDpi

1// Create SanitizeOptions object to set input and output files
2var options = new SanitizeOptions("path_to_your_pdf_file.pdf", "path_to_result_pdf_file.pdf");
3// Turn on conversion and set dpi
4options.ConvertPagesToImages = true;
5options.ImageDpi = 200;
6// Perform the process
7PdfSecurity.Sanitize(options);

如何在不删除 JavaScript 和操作的情况下进行清理

只需将 RemoveJavaScriptsAndActions 属性设为 false

1// Create SanitizeOptions object to set input and output files
2var options = new SanitizeOptions("path_to_your_pdf_file.pdf", "path_to_result_pdf_file.pdf");
3options.RemoveJavaScriptsAndActions = false;
4// Perform the process
5PdfSecurity.Sanitize(options);

最简方式清理 PDF 文件

1PdfSecurity.Sanitize(new SanitizeOptions("path_to_your_pdf_file.pdf", "path_to_result_pdf_file.pdf"));

关键特性:

  • 清理 PDF 文档:清除文档中可能存在的危险数据。
  • 可自定义选项:选择要删除的内容和保留的内容。
  • 转换为图像:将页面转换为图像,同时保持 PDF 形式。
 中文