PDF Form 的子部分

扁平化表单字段

The Documentize PDF Form for .NET allows you to convert interactive PDF forms into non-editable documents, making them secure from unauthorized modifications. This tool transforms form fields into static content, enhancing the security of your PDF documents. It is particularly useful when you need to secure contracts, agreements, or any document where form fields must remain unchanged.

如何在 PDF 中扁平化表单字段

要在 PDF 文档中扁平化表单字段,请按照以下步骤操作:

  1. 创建 FlattenFieldsOptions 类的实例。
  2. 将输入文件和输出文件添加到选项中。
  3. 调用 Flatten 方法执行扁平化操作。
1// Create FlattenFieldsOptions object to set instructions
2var options = new FlattenFieldsOptions();
3// Add input file path
4options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
5// Set output file path
6options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
7// Perform the process
8PdfForm.Flatten(options);

如何获取 PDF 中的所有字段

您可以获取文档中包含多少个字段的信息。

1// Get Fields Names
2var fieldNames = PdfForm.GetNames(new GetFieldNamesOptions("path_to_your_pdf_file.pdf"));

如何在 PDF 中扁平化除第一个字段以外的所有内容

您可以根据字段的位置或名称等条件有选择地仅扁平化特定表单字段。

 1// Get Fields Names
 2var fieldNames = PdfForm.GetNames(new GetFieldNamesOptions("path_to_your_pdf_file.pdf"));
 3// Create FlattenFieldsOptions object to set instructions
 4var options = new FlattenFieldsOptions();
 5options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
 6options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
 7// Skip 1 field.
 8options.SkipFields.Add(fieldNames[0]);
 9// Perform the process
10PdfForm.Flatten(options);

关键特性:

  • Flatten All Form Fields: Converts interactive form fields into non-editable static content.
  • Get Fields Names: Get fields names in a PDF.
  • Flatten Selected Fields: Optionally flatten specific fields in a PDF while keeping others editable.
 中文