v26.5
新功能:PDF 安全净化
- 从 PDF 文档中清除隐藏数据,确保删除或转换诸如元数据、附件、批注、JavaScript、表单、图层、搜索索引或私有内容等敏感或不必要的信息。
- Class PdfSecurity:新增方法 Sanitize 用于对 PDF 文档进行净化。
- Class SanitizeOptions:表示 PdfSecurity 类中用于净化文档隐藏数据的配置选项。
- Property Input:获取或设置输入数据。
- Property Output:获取或设置输出数据。
- Property ConvertPagesToImages:获取或设置将页面转换为图像的选项。
- Property ImageDpi:获取或设置在页面转图像过程中解析页面图像的 DPI。
- Property RemoveAnnotations:获取或设置一个值,指示是否从文档中移除批注。
- Property RemoveSearchIndexAndPrivateInfo:获取或设置一个值,指示是否应从文档中移除搜索索引和私有信息。
- Property FlattenForms:获取或设置一个值,指示在净化过程中是否应将文档中的表单扁平化。
- Property FlattenLayers:获取或设置在 PDF 文档中扁平化图层的选项。
- Property RemoveJavaScriptsAndActions:获取或设置一个值,指示是否应从文档中移除 JavaScript 及其关联操作。
- Property RemoveMetadata:获取或设置一个选项,以从文档中移除元数据。
- Property RemoveAttachments:获取或设置一个选项,以从文档中移除所有附件文件。
示例用法:
示例演示如何对 PDF 文档进行净化。
// Create SanitizeOptions object to set input and output files
var options = new SanitizeOptions("path_to_your_pdf_file.pdf", "path_to_result_pdf_file.pdf");
// Perform the process
PdfSecurity.Sanitize(options);示例用法:
示例演示如何从流到流进行 PDF 净化。
// Prepare input and output streams
using var inputStream = File.OpenRead("path_to_your_pdf_file.pdf");
using var outputStream = new MemoryStream();
// Create SanitizeOptions object to set input and output streams
var options = new SanitizeOptions(inputStream, outputStream);
// Perform the process
PdfSecurity.Sanitize(options);示例用法:
示例演示如何从文件到流进行 PDF 净化。
// Prepare output stream
using var outputStream = new MemoryStream();
// Create SanitizeOptions object to set input file and output stream
var options = new SanitizeOptions("path_to_your_pdf_file.pdf", outputStream);
// Perform the process
PdfSecurity.Sanitize(options);示例用法:
示例演示如何通过手动设置 Input 和 Output 属性进行 PDF 净化。
// Create SanitizeOptions object
var options = new SanitizeOptions();
//Set Input file
options.Input = new FileData("path_to_your_pdf_file.pdf");
//Set Output file
options.Output = new FileData("path_to_result_pdf_file.pdf");
// Perform the process
PdfSecurity.Sanitize(options);示例用法:
示例演示如何在不移除元数据的情况下进行 PDF 净化。
// Create SanitizeOptions object to set input and output files
var options = new SanitizeOptions("path_to_your_pdf_file.pdf", "path_to_result_pdf_file.pdf");
options.RemoveMetadata = false;
// Perform the process
PdfSecurity.Sanitize(options);示例用法:
示例演示如何在不移除附件的情况下进行 PDF 净化。
// Create SanitizeOptions object to set input and output files
var options = new SanitizeOptions("path_to_your_pdf_file.pdf", "path_to_result_pdf_file.pdf");
options.RemoveAttachments = false;
// Perform the process
PdfSecurity.Sanitize(options);示例用法:
示例演示如何将所有页面转换为图像并设置结果 DPI。
// Create SanitizeOptions object to set input and output files
var options = new SanitizeOptions("path_to_your_pdf_file.pdf", "path_to_result_pdf_file.pdf");
// Turn on conversion and set dpi
options.ConvertPagesToImages = true;
options.ImageDpi = 200;
// Perform the process
PdfSecurity.Sanitize(options);示例用法:
示例演示如何在不移除 JavaScripts 和 Actions 的情况下进行 PDF 净化。
// Create SanitizeOptions object to set input and output files
var options = new SanitizeOptions("path_to_your_pdf_file.pdf", "path_to_result_pdf_file.pdf");
options.RemoveJavaScriptsAndActions = false;
// Perform the process
PdfSecurity.Sanitize(options);示例用法:
示例演示以最简方式对 PDF 文件进行净化。
PdfSecurity.Sanitize(new SanitizeOptions("path_to_your_pdf_file.pdf", "path_to_result_pdf_file.pdf"));新类 OptionsWithInputAndOutput
- 代表具有 1 个输入数据和 1 个输出数据的操作的基础 Options。
- 基于 OptionsWithInput。
- Property Input:获取或设置输入数据。
- Property Output:获取或设置输出数据。
改进 PDF 转 JPEG 的转换性能
更新本站产品页 “FAQs”
https://docs.documentize.com/faqs/
其他修复
- 修复大型 HTML 转 PDF 的转换速度问题
- 修复 PDF 转 HTML 时出现的 OutOfMemoryException
- 修复 PDF 转 PDFA 时页面内容被截断的问题
- 修复 PDF 转 PDFA 时透明图像渲染问题
- 修复 PDF 转 PDFA2b 时注释在输出中丢失的问题
- 修复 PDF 转 PDF/A 时图像在输出文件中出现倒置
- 修复 PDF 转 PDF/A 时生成的文件未通过 PDF/A_2a 合规性检查
- 修复 PDF 转 PDF/A 时生成的文件未通过合规性检查
- 修复 PDF 转 PDF/A 时签名在转换后变黑
- 修复 PDF 转 PDF/A 时文字对齐意外更改
- 修复 PDF 转 PNG 时转换耗时过长
- 修复 PDF 转 PNG 时输出图像不正确
- 修复 PDF 转 PNG 时输出图像出现暗色条纹
- 修复无法验证文档的 PDF/A_1b 合规性