使用 Documentize 的 .NET 工具轻松合并 PDF——将多个文件合并为一个,同时保持质量和结构。
使用 Documentize 的 .NET 工具轻松拆分 PDF —— 提取页面、创建新文件,并精准管理文档
使用 Documentize 的 .NET 工具轻松合并 PDF——将多个文件合并为一个,同时保持质量和结构。
使用 Documentize 的 .NET 工具轻松拆分 PDF —— 提取页面、创建新文件,并精准管理文档
轻松使用 Documentize PDF Manager 调整 PDF 文档的页面大小
轻松使用 Documentize PDF Manager 旋转 PDF 文档的页面
使用 Documentize PDF Manager 轻松压缩您的 PDF 文档
使用 Documentize 的 .NET 工具轻松优化 PDF——减小文件大小,提高性能,同时保持质量
使用 Documentize 的 .NET 工具生成专业的 PDF 表格——轻松自定义布局、样式和数据。
通过动态生成目录(TOC)来增强 PDF 文档的组织和导航
使用 Documentize 的 ChatGPT 集成,通过 AI 增强您的 PDF——智能生成、编辑和分析内容。
使用 Documentize 的 .NET 工具加密 PDF 文件,以保护敏感信息。
使用 Documentize 的 .NET 工具解密您的 PDF 文件,以打开文档。
使用 Documentize 的 .NET 工具加密 PDF 文件,以保护敏感信息。
使用 Documentize 的 .NET 工具解密您的 PDF 文件,以打开文档。
使用 Documentize 的 .NET 工具对 PDF 文件进行数字签名——轻松实现安全性、真实性和合规性。
将交互式 PDF 表单转换为不可编辑的文档,使其免受未授权的修改
将交互式 PDF 表单转换为不可编辑的文档,使其免受未授权的修改
开发者指南 的子部分
PDF Converter
使用 Documentize 的 .NET 工具将 HTML 转换为 PDF——保留布局和格式,实现一致、专业的效果。
使用 Documentize 的 .NET 工具将 PDF 转换为 Word 文档——保留格式和结构,便于编辑。
使用 Documentize 的 .NET 工具将 PDF 转换为 HTML——保留布局和格式,确保一致且专业的效果。
使用 Documentize 的 .NET 工具将 PDF 转换为 JPEG 图像——轻松从文档中提取高质量图像。
使用 Documentize 的 .NET 工具将 PDF 转换为 PDF/A 格式——轻松确保长期归档和合规性。
使用 Documentize 的 .NET 工具将 PDF 转换为 PNG 图像——提取高质量图像用于网页和图形用途。
使用 Documentize 的 .NET 工具将 PDF 转换为 TIFF 图像——提取高分辨率图像,实现专业文档管理。
使用 Documentize 的 .NET 工具将 PDF 转换为 Excel——快速提取表格和数据,实现无缝分析和处理。
PDF Converter 的子部分
HTML to PDF
Documentize PDF Converter for .NET 提供强大的 HTML 到 PDF 格式转换功能,适用于网页应用、归档和报告生成。通过多种资源和布局处理选项,转换器可以适配各种项目需求。
将 HTML 转换为 PDF
将 HTML 内容转换为高质量的 PDF,完美用于生成可打印的报告、归档网页内容或创建可共享的文档格式。
要将 HTML 文档转换为 PDF,请按照以下步骤操作:
- 配置选项:使用
HtmlToPdfOptions 定义布局和媒体设置。 - 指定路径:设置输入 HTML 和输出 PDF 文件的路径。
- 执行转换:调用
PdfConverter 的 Convert 方法进行转换。
示例:将 HTML 转换为 PDF
1// Create HtmlToPdfOptions
2var options = new HtmlToPdfOptions();
3// Add input file path
4options.AddInput(new FileData("path_to_input.html"));
5// Set output file path
6options.AddOutput(new FileData("path_to_output.pdf"));
7//Perform the process
8PdfConverter.Convert(options);
HTML 转 PDF 转换的其他选项
媒体类型:
HtmlMediaType.Print:适用于生成适合打印的 PDF。HtmlMediaType.Screen:用于转换面向数字显示的内容。
布局调整:
PageLayoutOption:调整 HTML 内容如何适配 PDF 布局,例如 ScaleToPageWidth 可确保内容按 PDF 宽度进行缩放。IsRenderToSinglePage:如有需要,可将整个 HTML 内容渲染到单个 PDF 页面,以实现简洁的展示。
该转换器在各种应用场景中都非常灵活,无论是基于网页内容生成 PDF 报告,还是将 PDF 文档归档转换为网页可访问形式。欲了解更高级的配置,请参阅完整的 Documentize 文档。
PDF to DOC
Documentize PDF Converter for .NET 是一个强大的工具,旨在将 PDF 文档转换为 DOC 格式。该组件可以无缝地将 PDF 页面转换为可编辑的 Microsoft Word 文档,轻松实现内容的重用、编辑和跨平台共享。
如何将 PDF 转换为 DOC
将 PDF 文档转换为 DOC 格式,请按照以下步骤操作:
- 创建
PdfToDocOptions 实例以配置转换过程。 - 使用
AddInput 方法添加输入的 PDF 文件。 - 使用
AddOutput 方法添加输出文件的路径。 - 调用
Convert 方法执行转换。
1// Create PdfToDocOptions object to set instructions
2var options = new PdfToDocOptions();
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_file.doc"));
7// Perform the process
8PdfConverter.Convert(options);
使用自定义选项将 PDF 转换为 DOC
PDF to DOC Converter 插件提供了多种选项,以自定义转换过程。您可以在不同模式之间选择,以控制在转换期间如何处理 PDF 的布局和结构。
1// Create PdfToDocOptions object to set instructions
2var options = new PdfToDocOptions();
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_file.doc"));
7// Set Mode
8options.Mode = DocConversionMode.Flow;
9// Perform the process
10PdfConverter.Convert(options);
关键特性:
- DOC 转换:将 PDF 文档转换为可编辑的 Microsoft Word 格式(DOC)。
- 保持格式:在转换过程中保留原始的布局、文本和格式。
PDF 转 HTML
Documentize PDF Converter for .NET 提供了强大的 PDF 转 HTML 功能,适用于 Web 应用、归档以及报表生成。通过多种资源和布局处理选项,转换器能够满足各种项目需求。
将 PDF 转换为 HTML
将 PDF 文件转换为 HTML,使文档能够在网页上查看或集成到更偏好 HTML 格式的应用中。
- 配置选项:使用
PdfToHtmlOptions 自定义输出,可选择嵌入式资源或外部资源。 - 定义输入输出路径:设置输入 PDF 和输出 HTML 的路径。
- 执行转换:调用
PdfConverter 的 Convert 方法进行转换。
示例:使用嵌入式资源将 PDF 转换为 HTML
1// Create PdfToHtmlOptions object to set output data type as file with embedded resources
2var options = new PdfToHtmlOptions(PdfToHtmlOptions.SaveDataType.FileWithEmbeddedResources);
3// Add input file path
4options.AddInput(new FileData("path_to_input.pdf"));
5// Set output file path
6options.AddOutput(new FileData("path_to_output.html"));
7//Perform the process
8PdfConverter.Convert(options);
PDF 转 HTML 转换的可用选项
- SaveDataType:
FileWithEmbeddedResources:生成一个包含所有资源的单一 HTML 文件。FileWithExternalResources:资源单独保存,适用于大的 HTML 文件。
PDF 转 JPEG
The Documentize PDF Converter for .NET 是一款强大的工具,简化了将 PDF 文档转换为高质量 JPEG 图像的过程。该组件旨在通过将 PDF 页面转换为广泛使用的图像格式,使您的内容在各平台上更易访问。
如何将 PDF 页面转换为 JPEG
要将 PDF 文档转换为 JPEG 图像,请按以下步骤操作:
- 创建
PdfToJpegOptions 实例以配置转换过程。 - 使用
AddInput 方法添加输入 PDF 文件。 - 使用
AddOutput 方法设置 JPEG 图像的输出目录路径。 - 调用
Convert 方法将 PDF 页面转换为 JPEG 图像。
1// Create PdfToJpegOptions object to set instructions
2var options = new PdfToJpegOptions();
3// Add input File path
4options.AddInput(new FileData("path_to_input.pdf"));
5// Set output Directory path
6options.AddOutput(new DirectoryData("path_to_output_directory"));
7// Perform the process
8PdfConverter.Convert(options);
定制 PDF 转 JPEG 转换
您可以通过调整分辨率、选择页面范围或设置图像质量来自定义转换过程。以下示例演示如何以 200 DPI 将 PDF 的第一页转换为 JPEG:
1// Create PdfToJpegOptions object to set instructions
2var options = new PdfToJpegOptions();
3// Process only the first page
4options.PageList = [1];
5// Set output resolution to 200 DPI
6options.OutputResolution = 200;
7// Set output quality to 50
8options.Quality = 50;
9// Add input File path
10options.AddInput(new FileData("path_to_input.pdf"));
11// Set output Directory path
12options.AddOutput(new DirectoryData("path_to_output_directory"));
13// Perform the process
14PdfConverter.Convert(options);
如何在不使用目录或以流的形式获取结果
Convert 方法返回一个 ResultContainer 对象,包含转换结果的信息。您可以按以下方式获取转换后 JPEG 文件的流:
1// Create PdfToJpegOptions object to set instructions
2var options = new PdfToJpegOptions();
3// Add input File path
4options.AddInput(new FileData("path_to_input.pdf"));
5// Perform the process
6var results = PdfConverter.Convert(options);
7// Get stream results
8foreach (var result in results.ResultCollection)
9{
10 var streamResultPage1 = result.ToStream();
11}
关键特性
- Convert PDF to JPEG:轻松将整个 PDF 文档或特定页面转换为 JPEG 图像。
- Custom Resolution:可调节分辨率(例如 300 dpi),获得高质量输出。
- Page set:选择要转换的特定页面。
- Quick Conversion:快速高效,耗时少。
PDF 转 PDF/A
The Documentize PDF Converter for .NET is a powerful tool designed to convert PDF documents into the PDF/A format, ensuring that your content remains compliant with long-term archiving standards. This component also supports validating existing PDF documents for PDF/A compliance, offering both conversion and validation features in a single solution.
如何将 PDF 转换为 PDF/A
To convert a PDF document into PDF/A format, follow these steps:
- Create an instance of
PdfToPdfAOptions to configure the conversion. - Specify the desired PDF/A version (e.g., PDF/A-3B).
- Add the input PDF file using the
AddInput method. - Add the output file for the resulting PDF/A using the
AddOutput method. - Call the
Convert method to execute the conversion.
1// Create the options class to set up the conversion process
2var options = new PdfToPdfAOptions
3{
4 PdfAVersion = PdfAStandardVersion.PDF_A_3B
5};
6
7// Add the source file
8options.AddInput(new FileData("path_to_your_pdf_file.pdf")); // replace with your actual file path
9
10// Add the path to save the converted file
11options.AddOutput(new FileData("path_to_the_converted_file.pdf"));
12
13// Run the conversion
14PdfConverter.Convert(options);
验证 PDF/A 合规性
You can validate existing PDF files for PDF/A compliance using the PdfAValidateOptions class.
1// Create the options class to set up the validation process
2var options = new PdfAValidateOptions
3{
4 PdfAVersion = PdfAStandardVersion.PDF_A_1A
5};
6
7// Add one or more files to be validated
8options.AddInput(new FileData("path_to_your_first_pdf_file.pdf")); // replace with your actual file path
9options.AddInput(new FileData("path_to_your_second_pdf_file.pdf"));
10// add more files as needed
11
12// Run the validation and get results
13var resultContainer = PdfConverter.Validate(options);
14
15// Check the resultContainer.ResultCollection property for validation results for each file:
16foreach (var result in resultContainer.ResultCollection)
17{
18 var validationResult = (PdfAValidationResult) result.Data;
19 var isValid = validationResult.IsValid; // Validation result for document
20}
关键特性:
- Convert to PDF/A: Seamlessly transform PDF files into the PDF/A format (such as PDF/A-1a, PDF/A-2b, PDF/A-3b) to ensure compliance with archiving standards.
- Validate PDF/A Compliance: Check existing PDF documents for conformance with PDF/A standards and identify issues if they do not comply.
- Efficient Workflow: Minimize time and effort with fast and reliable conversion processes.
PDF to PNG
Documentize PDF Converter for .NET 是一款高级工具,可将 PDF 文档转换为高质量的 PNG 图像。该组件旨在通过将 PDF 页面转化为广泛支持的图像格式,使您的内容更加多用途、可访问且易于共享。
如何将 PDF 转换为 PNG
将 PDF 文档转换为 PNG 图像,请按以下步骤操作:
- 创建
PdfToPngOptions 实例以配置转换过程。 - 使用
AddInput 方法添加输入 PDF 文件。 - 使用
AddOutput 方法设置 PNG 图像的输出目录路径。 - 调用
Convert 方法将 PDF 页面转换为 PNG 图像。
1// Create PdfToPngOptions object to set instructions
2var options = new PdfToPngOptions();
3// Add input File path
4options.AddInput(new FileData("path_to_input.pdf"));
5// Set output Directory path
6options.AddOutput(new DirectoryData("path_to_output_directory"));
7// Perform the process
8PdfConverter.Convert(options);
自定义 PDF 到 PNG 的转换
您可以通过调节分辨率和选择特定页面来自定义转换。例如,仅以 200 DPI 将 PDF 的第一页转换为 PNG:
1// Create PdfToPngOptions object to set instructions
2var options = new PdfToPngOptions()
3// Process only the first page
4options.PageList = [1];
5// Set output resolution to 200 DPI
6options.OutputResolution = 200;
7// Add input File path
8options.AddInput(new FileData("path_to_input.pdf"));
9// Set output Directory path
10options.AddOutput(new DirectoryData("path_to_output_directory"));
11// Perform the process
12PdfConverter.Convert(options);
处理转换结果
Convert 方法返回一个 ResultContainer 对象,包含转换结果信息。您可以按以下方式获取已转换 PNG 文件的流:
1// Create PdfToJpegOptions object to set instructions
2var options = new PdfToPngOptions();
3// Add input File path
4options.AddInput(new FileData("path_to_input.pdf"));
5// Perform the process
6var results = PdfConverter.Convert(options);
7// Get stream results
8foreach (var result in results.ResultCollection)
9{
10 var streamResultPage1 = result.ToStream();
11}
主要特性:
- 将 PDF 转换为 PNG:快速高效地将整个 PDF 文档或特定页面转换为 PNG 图像。
- 可自定义分辨率:设置所需的 DPI(例如 300 DPI),以获得高质量图像输出。
- 页面集:选择要转换的特定页面。
- 易于输出管理:为每个转换后的 PNG 文件指定输出目录。
- 快速转换:快速、高效,配置工作量极小。
PDF 转 TIFF
The Documentize PDF Converter for .NET 是一个强大的工具,旨在将 PDF 文档转换为高质量的 TIFF 图像。该组件确保您的内容能够在各种平台上访问,同时保持出色的保真度和多功能性。您可以通过调整分辨率、启用多页输出或选择特定页面来自定义转换过程。
How to Convert PDF to TIFF
要将 PDF 文档转换为 TIFF 图像,请按照以下步骤操作:
- 创建
PdfToTiffOptions 实例以配置转换过程。 - 使用
AddInput 方法添加输入 PDF 文件。 - 使用
AddOutput 方法指定 TIFF 图像的输出文件路径。 - 运行
Convert 方法将 PDF 页面转换为 TIFF 图像。
1// Create PdfToTiffOptions object to set instructions
2var options = new PdfToTiffOptions();
3// Add input file path
4options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
5// Set output Directory path
6options.AddOutput(new DirectoryData("path_to_output_directory"));
7// Perform the process
8PdfConverter.Convert(options);
Customizing Pages and DPI of PDF to TIFF Conversion
以下示例展示如何将 PDF 的 2 页以 400 DPI 转换为 TIFF 文件:
1// Create PdfToTiffOptions object to set instructions
2var options = new PdfToTiffOptions();
3// Add input file path
4options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
5// Set output Directory path
6options.AddOutput(new DirectoryData("path_to_output_directory"));
7// Set Pages
8options.PageList = [1, 3];
9// Set result image Resolution
10options.OutputResolution = 400;
11// Perform the process
12PdfConverter.Convert(options);
Multi-Page TIFF Creation
该插件支持多页 TIFF 生成,允许您将多个 PDF 页面合并为单个 TIFF 文件,以实现高效的归档或打印。
1// Create PdfToTiffOptions object to set instructions
2var options = new PdfToTiffOptions();
3// Add input file path
4options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
5// Set output Directory path
6options.AddOutput(new DirectoryData("path_to_output_directory"));
7// Enable Multi-Page TIFF output
8options.MultiPage = true;
9// Perform the process
10PdfConverter.Convert(options);
Customizing Pages and DPI of PDF to TIFF Conversion
以下示例展示如何将 PDF 的 2 页以 400 DPI 转换为 TIFF 文件,并设置压缩和颜色深度:
1// Create PdfToTiffOptions object to set instructions
2var options = new PdfToTiffOptions();
3// Add input file path
4options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
5// Set output Directory path
6options.AddOutput(new DirectoryData("path_to_output_directory"));
7// Set Compression and ColorDepth
8options.Compression = TiffCompression.RLE;
9options.ColorDepth = TiffColorDepth.Format24bpp;
10// Perform the process
11PdfConverter.Convert(options);
How to Handle Conversion Results
Convert 方法返回一个 ResultContainer 对象,提供有关转换结果的详细信息。您可以像下面这样获取转换后 TIFF 文件的流:
1// Create PdfToTiffOptions object to set instructions
2var options = new PdfToTiffOptions();
3// Add input File path
4options.AddInput(new FileData("path_to_input.pdf"));
5// Perform the process
6var results = PdfConverter.Convert(options);
7// Get stream results
8foreach (var result in results.ResultCollection)
9{
10 var streamResultPage1 = result.ToStream();
11}
Key Features:
- Convert PDF to TIFF:轻松将整个 PDF 文档或特定页面转换为 TIFF 图像。
- Custom Resolution:调整分辨率(例如 300 dpi),以获得更高质量的输出。
- Multi-Page TIFF:将多个 PDF 页面合并为单个多页 TIFF 文件。
- Page set:选择特定页面进行转换。
- Quick Conversion:快速高效的处理过程,几乎无需额外操作。
PDF 转 XLS
The Documentize PDF Converter for .NET 是一个多功能且强大的工具,可将 PDF 文档转换为 Excel 电子表格(XLSX/XLS/CSV/XLSM/ODS)。通过使用此组件,开发人员可以轻松地将静态 PDF 数据转化为可编辑的动态电子表格,从而简化数据操作、分析和共享。
如何将 PDF 转换为 Excel
将 PDF 文档转换为 Excel 文件(XLSX),请按以下步骤操作:
- 使用
PdfToXlsOptions 类配置转换设置。 - 使用
AddInput 方法添加输入 PDF 文件。 - 使用
AddOutput 方法指定输出文件路径。 - 调用
Convert 方法执行转换。
1// Create PdfToXlsOptions object to set instructions
2var options = new PdfToXlsOptions();
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_xlsx_file.xlsx"));
7// Perform the process
8PdfConverter.Convert(options);
自定义 PDF 到 Excel 的转换
PdfToXlsOptions 类允许您自定义转换过程。例如,将 PDF 转换为 XLS 文件并启用高级格式化选项:
1// Create PdfToXlsOptions object to set instructions
2var options = new PdfToXlsOptions();
3// Add input file path
4options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
5// Specify XLS format
6options.Format = PdfToXlsOptions.ExcelFormat.XMLSpreadSheet2003;
7options.InsertBlankColumnAtFirst = true;
8options.MinimizeTheNumberOfWorksheets = true;
9// Set output file path
10options.AddOutput(new FileData("path_to_result_xlsx_file.xls"));
11// Perform the process
12PdfConverter.Convert(options);
支持的输出格式
PdfToXlsOptions.ExcelFormat 枚举提供了多种输出格式:
- XLSX:Office Open XML(.xlsx)文件格式(默认)。
- XLSM:支持宏的 Excel 格式。
- CSV:逗号分隔值。
- ODS:Open Document Spreadsheet。
- XMLSpreadSheet2003:Excel 2003 XML(.xls)文件格式。
主要特性:
- 灵活的转换选项:将 PDF 文件转换为 XLSX、XLS、CSV 或其他格式。
- 内容保留:保持原始结构、布局和格式。
- 高级格式化:插入空列或最小化工作表数量。
使用 Documentize 的 .NET 工具准确提取 PDF 文档中的文本——轻松检索、处理和分析内容。
在 .NET 应用程序中轻松从 PDF 文档中提取图像
使用 Documentize 在 C#/.NET 中准确提取 PDF 的元数据
使用 C#/.NET 从 PDF 表单(AcroForms)提取并导出数据为 CSV 等其他格式
PDF Extractor 的子部分
提取文本
The Documentize PDF Extractor for .NET 简化了从 PDF 文档中提取文本的过程。无论您需要纯文本、原始文本还是普通文本,此插件都能高效提取文本,并根据需求保留或省略格式。
如何从 PDF 文件提取文本
要从 PDF 文件提取文本,请按照以下步骤操作:
- 创建
ExtractTextOptions 实例以配置输入文件路径。 - 运行
Extract 方法进行文本提取。
1// Create ExtractTextOptions object to set input file path
2var options = new ExtractTextOptions("path_to_your_pdf_file.pdf");
3// Perform the process and get the extracted text
4var textExtracted = PdfExtractor.Extract(options);
如何从 PDF 流提取文本
要从 PDF 流提取文本,请按照以下步骤操作:
- 创建
ExtractTextOptions 实例以配置输入流。 - 运行
Extract 方法进行文本提取。
1// Create ExtractTextOptions object to set input stream
2var stream = File.OpenRead("path_to_your_pdf_file.pdf");
3var options = new ExtractTextOptions(stream);
4// Perform the process and get the extracted text
5var textExtracted = PdfExtractor.Extract(options);
文本提取模式
ExtractTextOptions 提供三种提取模式,满足不同需求的灵活性。
- Pure Mode:保留原始格式,包括空格和对齐。
- Raw Mode:不保留格式,适用于原始数据处理。
- Flatten Mode:使用坐标表示 PDF 内容的文本片段。
1// Create ExtractTextOptions object to set input file path and TextFormattingMode
2var options = new ExtractTextOptions("path_to_your_pdf_file.pdf", TextFormattingMode.Pure);
3// Perform the process and get the extracted text
4var textExtracted = PdfExtractor.Extract(options);
最简方式从 PDF 文件提取文本
1// Perform the process and get the extracted text
2var textExtracted = PdfExtractor.Extract(new ExtractTextOptions("path_to_your_pdf_file.pdf", TextFormattingMode.Pure));
关键特性:
- Pure Mode:在保留原始格式的同时提取文本。
- Raw Mode:提取不含任何格式的文本。
- Flatten Mode:提取不含特殊字符或格式的文本。
提取图像
The Documentize PDF Extractor for .NET 插件使您能够轻松从 PDF 文档中提取图像。它会扫描您的 PDF 文件,识别嵌入的图像,并在保持原始质量和格式的同时提取它们。此工具提升了视觉内容的可访问性,并简化了从 PDF 中检索图像的过程。
如何从 PDF 中提取图像
要从 PDF 文件中提取图像,请按照以下步骤操作:
- 创建
ExtractImagesOptions 类的实例。 - 使用
AddInput 方法将输入文件路径添加到选项中。 - 使用
AddOutput 方法设置图像的输出目录路径。 - 使用插件执行图像提取过程。
- 从结果容器中获取提取的图像。
1// Create ExtractImagesOptions to set instructions
2var options = new ExtractImagesOptions();
3// Add input file path
4options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
5// Set output Directory path
6options.AddOutput(new DirectoryData("path_to_results_directory"));
7// Perform the process
8var results = PdfExtractor.Extract(options);
9// Get path to image result
10var imageExtracted = results.ResultCollection[0].ToFile();
在不使用文件夹的情况下将 PDF 文件的图像提取到流
PdfExtractor 插件支持保存到流,这使您可以在不使用临时文件夹的情况下将 PDF 文件中的图像提取到流中。
1// Create ExtractImagesOptions to set instructions
2var options = new ExtractImagesOptions();
3// Add input file path
4options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
5// Not set output - it will write results to streams
6// Perform the process
7var results = PdfExtractor.Extract(options);
8// Get Stream
9var ms = results.ResultCollection[0].ToStream();
10// Copy data to file for demo
11ms.Seek(0, SeekOrigin.Begin);
12using (var fs = File.Create("test_file.png"))
13{
14 ms.CopyTo(fs);
15}
主要功能:
- 提取嵌入图像:识别并提取 PDF 文档中的图像。
- 保留图像质量:确保提取的图像保持原始质量。
- 灵活的输出:以您偏好的格式或位置保存提取的图像。
The Documentize PDF Extractor for .NET simplifies extracting Metadata from PDF documents.
Available properties that may interest you: FileName, Title, Author, Subject, Keywords, Created, Modified, Application, PDF Producer, Number of Pages.
如何从 PDF 文件中提取元数据
The example demonstrates how to Extract Properties (Title, Author, Subject, Keywords, Number of Pages) from PDF file.
To extract metadata from a PDF document, follow these steps:
- Create an instance of
ExtractPropertiesOptions to configure the extraction options and input PDF file. - Run the
Extract method of PdfExtractor to extract the metadata. - Access the extracted properties using the
PdfProperties.
1// Create ExtractPropertiesOptions object to set input file
2var options = new ExtractPropertiesOptions("path_to_your_pdf_file.pdf");
3// Perform the process and get Properties
4var pdfProperties = PdfExtractor.Extract(options);
5var filename = pdfProperties.FileName;
6var title = pdfProperties.Title;
7var author = pdfProperties.Author;
8var subject = pdfProperties.Subject;
9var keywords = pdfProperties.Keywords;
10var created = pdfProperties.Created;
11var modified = pdfProperties.Modified;
12var application = pdfProperties.Application;
13var pdfProducer = pdfProperties.PdfProducer;
14var numberOfPages = pdfProperties.NumberOfPages;
如何从 PDF 流中提取元数据
You can open the stream at your own discretion.
1// Create ExtractPropertiesOptions object to set input stream
2var stream = File.OpenRead("path_to_your_pdf_file.pdf");
3var options = new ExtractPropertiesOptions(stream);
4// Perform the process and get Properties
5var pdfProperties = PdfExtractor.Extract(options);
6var title = pdfProperties.Title;
7var author = pdfProperties.Author;
8var subject = pdfProperties.Subject;
9var keywords = pdfProperties.Keywords;
10var created = pdfProperties.Created;
11var modified = pdfProperties.Modified;
12var application = pdfProperties.Application;
13var pdfProducer = pdfProperties.PdfProducer;
14var numberOfPages = pdfProperties.NumberOfPages;
以最简洁方式从 PDF 文件中提取元数据
1// Perform the process and get Properties
2var pdfProperties = PdfExtractor.Extract(new ExtractPropertiesOptions("path_to_your_pdf_file.pdf"));
关键特性:
- 可用的元数据:FileName、Title、Author、Subject、Keywords、Created、Modified、Application、PDF Producer、Number of Pages.
导出表单数据
The Documentize PDF Extractor for .NET plugin provides a seamless way to extract and export data from PDF forms (AcroForms) into other formats like CSV. This dynamic tool simplifies the process of retrieving form field values, allowing for easy data management, transfer, and analysis.
To export form data from a PDF to CSV, follow these steps:
- Create an instance of the
ExtractImagesOptions class. - Define export options using the
FormExporterValuesToCsvOptions class. - Add input PDF files and specify the output CSV file.
- Run the
Extract method to perform the export.
1// Create ExtractFormDataToDsvOptions object to set instructions
2var options = new ExtractFormDataToDsvOptions(',', true);
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_csv_file.csv"));
7// Perform the process
8PdfExtractor.Extract(options);
Use Tab as Delimiter.
1// Create ExtractFormDataToDsvOptions object to set instructions
2var options = new ExtractFormDataToDsvOptions();
3//Set Delimiter
4options.Delimiter = '\t';
5//Add Field Names to result
6options.AddFieldName = true;
7// Add input file path
8options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
9// Set output file path
10options.AddOutput(new FileData("path_to_result_csv_file.tsv"));
11// Perform the process
12PdfExtractor.Extract(options);
Key Features:
- Export Form Data: Extract data from PDF forms (AcroForms) into CSV or other formats.
- Data Filtering: Use predicates to filter specific form fields for export based on criteria like field type or page number.
- Flexible Output: Save exported data for analysis or transfer to spreadsheets, databases, or other document formats.
PDF Manager
使用 Documentize 的 .NET 工具轻松合并 PDF——将多个文件合并为一个,同时保持质量和结构。
使用 Documentize 的 .NET 工具轻松拆分 PDF —— 提取页面、创建新文件,并精准管理文档
轻松使用 Documentize PDF Manager 调整 PDF 文档的页面大小
轻松使用 Documentize PDF Manager 旋转 PDF 文档的页面
使用 Documentize PDF Manager 轻松压缩您的 PDF 文档
使用 Documentize 的 .NET 工具轻松优化 PDF——减小文件大小,提高性能,同时保持质量
使用 Documentize 的 .NET 工具生成专业的 PDF 表格——轻松自定义布局、样式和数据。
通过动态生成目录(TOC)来增强 PDF 文档的组织和导航
使用 Documentize 的 ChatGPT 集成,通过 AI 增强您的 PDF——智能生成、编辑和分析内容。
PDF Manager 的子部分
合并 PDF
Documentize PDF Manager for .NET 是一款多功能工具,旨在将多个 PDF 文档合并为单个文件。它简化了 PDF 文件的整合过程,确保文档高效合并并在内容上保持一致性。该组件会处理字体、图像等内部资源,以优化合并后的文档。
如何合并 PDF
将多个 PDF 文档合并为单个文件,请按以下步骤操作:
- 创建
MergeOptions 实例以配置合并过程。 - 使用
AddInput 方法添加输入 PDF 文件。 - 使用
AddOutput 方法添加输出 PDF 文件。 - 调用
PdfManager 类的 Merge 方法执行合并。
1// Create MergeOptions object to set instructions
2var options = new MergeOptions();
3// Add input file paths
4options.AddInput(new FileData("path_to_your_pdf_file_1.pdf"));
5options.AddInput(new FileData("path_to_your_pdf_file_2.pdf"));
6// Set output file path
7options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
8// Perform the process
9PdfManager.Merge(options);
关键特性
- 合并多个 PDF:轻松将多个 PDF 文件合并为一个。
- 资源优化:合并时删除重复的字体和图像。
- 批量处理:一次性合并大量 PDF 文档。
拆分 PDF
The Documentize PDF Manager for .NET 是一个强大的工具,可简化将大型 PDF 文档拆分为更小、更易管理的文件的过程。无论是提取单个页面还是将文档划分为特定章节,该组件都能高效、低成本地帮助您实现目标。
How to Split PDF
要将 PDF 文档拆分为单独的页面,请按以下步骤操作:
- 创建
SplitOptions 实例以配置拆分选项。 - 使用
AddInput 方法添加输入 PDF 文件。 - 使用
AddOutput 方法为每个拆分页面添加输出文件。 - 调用
PdfManager 类中的 Split 方法执行拆分。
1// Create SplitOptions object to set instructions
2var options = new SplitOptions();
3// Add input file path
4options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
5// Set output file paths
6options.AddOutput(new FileData("path_to_result_pdf_file_1.pdf"));
7options.AddOutput(new FileData("path_to_result_pdf_file_2.pdf"));
8// Perform the process
9PdfManager.Split(options);
Key Features:
- Split PDF by Page: 将 PDF 文档拆分为单独的页面。
- Custom Split Options: 根据需求配置拆分过程。
- Organized Output: 轻松管理每个拆分页面或章节的输出文件。
调整 PDF 页面大小
您可以使用 PDF Manager 类来调整 PDF 文档的页面大小。创建 ResizeOptions 后,您可以设置所需的页面尺寸并执行缩放过程。结果 PDF 将体现新的尺寸,确保符合特定需求。
调整 PDF
要调整 PDF 文档的尺寸,需使用 ResizeOptions 类来指定文档的新页面大小。
- 创建一个
ResizeOptions 对象以定义页面尺寸。 - 添加输入文件并设置期望的输出位置。
- 使用
SetPageSize 方法指定新的尺寸(例如 A4)。 - 调用
PdfManager 的 Resize 方法。
1
2// Create ResizeOptions object to set instructions
3var options = new ResizeOptions();
4// Set new PageSize
5options.PageSize = PageSize.A3;
6// Add input file path
7options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
8// Set output file path
9options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
10// Perform the process
11PdfManager.Resize(options);
关键特性:
- Resizing:将页面调整为特定尺寸
- Available sizes:A0、A1、A2、A3、A4、A5、A6、B5、Letter、Legal、Ledger、11x17 英寸。
旋转 PDF 页面
您可以使用 PDF Manager 类来旋转 PDF 文档的页面。创建 RotateOptions 后,您可以设置所需的页面角度并执行此过程。生成的 PDF 将反映新的尺寸,确保符合特定要求。
旋转 PDF
使用 RotateOptions 类来调整 PDF 文件中页面的方向。
- 创建 RotateOptions 对象并配置旋转角度。
- 添加输入 PDF 文件并指定输出文件位置。
- 使用 SetRotation 方法设置旋转角度(例如,90 度)。
- 运行
PdfManager 的 Rotate 方法。
1// Create RotateOptions object to set instructions
2var options = new RotateOptions();
3// Set new Rotation
4options.Rotation = Rotation.On90;
5// Add input file path
6options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
7// Set output file path
8options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
9// Perform the process
10PdfManager.Rotate(options);
关键特性:
压缩 PDF
The PDF Manager 是一个综合工具,通过高级优化技术提升 PDF 文档。这些操作压缩 PDF 文档,使其更易于存储、分享和查看。
压缩 PDF
在可行的情况下,通过消除未使用的页面资源、合并相同的资产以及丢弃冗余对象来压缩 PDF 文档。
- 创建一个 CompressOptions 对象以配置优化设置。
- 添加输入文件并指定输出文件位置。
- 使用 SetCropBox 方法定义裁剪区域。
- 运行
PdfManager 的 Compress 方法。
1// Create CompressOptions object to set instructions
2var options = new CompressOptions();
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
8PdfManager.Compress(options);
关键特性:
- Compressing:从文档中删除未使用的页面资源和对象。
优化 PDF
PDF Manager 是一款综合工具,利用先进的优化技术提升 PDF 文档。它旨在帮助减小文件体积、旋转页面、裁剪内容以及调整文档尺寸。此类操作可提升 PDF 文件的质量和可管理性,使其更易于存储、共享和查看。优化(或称为 Web 线性化)是指使 PDF 文件适合在网页浏览器中在线浏览的过程。
优化 PDF
以下步骤演示如何在保持质量的前提下,通过减小文件大小来优化 PDF 文档。
- 创建一个 OptimizeOptions 对象以配置优化设置。
- 添加输入 PDF 文件并设置优化后文件的输出位置。
- 调用
PdfManager 的 Optimize 方法执行优化。
1
2// Create OptimizeOptions object to set instructions
3var options = new OptimizeOptions();
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
9PdfManager.Optimize(options);
关键特性:
- 优化:在不失真质量的前提下减小 PDF 文件大小。
Add Table
Documentize PDF Manager for .NET 是一个多功能组件,旨在简化将表格集成到 PDF 文档中的过程。无论是组织数据、设计表单,还是提升文档可读性,该组件都能在保持精确和高效的同时,使工作变得更简单。
创建带表格的 PDF
按照以下步骤使用 TableOptions 类在 PDF 中创建结构化表格:
- 配置
TableOptions 对象,以定义表格结构、内容以及输入/输出文件。 - 向 PDF 添加表格、行和单元格。
- 使用
AddTable 方法完成表格生成过程。
示例代码:
1// Configure table options
2var options = new TableOptions();
3options.InsertPageBefore(1)
4 .AddTable()
5 .AddRow()
6 .AddCell().AddParagraph("Name")
7 .AddCell().AddParagraph("Age")
8 .AddRow()
9 .AddCell().AddParagraph("Bob")
10 .AddCell().AddParagraph("12")
11 .AddRow()
12 .AddCell().AddParagraph("Sam")
13 .AddCell().AddParagraph("20")
14 .AddRow()
15 .AddCell().AddParagraph("Sandy")
16 .AddCell().AddParagraph("26")
17 .AddRow()
18 .AddCell().AddParagraph("Tom")
19 .AddCell().AddParagraph("12")
20 .AddRow()
21 .AddCell().AddParagraph("Jim")
22 .AddCell().AddParagraph("27");
23// Add input file path
24options.AddInput(new FileData("path_to_input.pdf"));
25// Set output file path
26options.AddOutput(new FileData("path_to_output.pdf"));
27// Perform the process
28PdfManager.AddTable(options);
设置表格所在页
按照以下步骤在第 2 页之前创建表格:
示例代码:
1// Configure table options
2var options = new TableOptions();
3options.InsertPageBefore(2) // Add table before page 2
4 .AddTable()
5 .AddRow()
6 .AddCell().AddParagraph("Name")
7 .AddCell().AddParagraph("Age");
8// Add input file path
9options.AddInput(new FileData("path_to_input.pdf"));
10// Set output file path
11options.AddOutput(new FileData("path_to_output.pdf"));
12// Perform the process
13PdfManager.AddTable(options);
关键特性:
- 动态表格创建:轻松在 PDF 文档中生成结构化表格。
- 页码定位:精准地在 PDF 的特定位置插入表格。
- 自定义布局:可调节表格结构、单元格对齐方式和样式。
添加目录
Documentize PDF Manager for .NET 是一个强大的组件,旨在通过动态生成目录(TOC)来增强 PDF 文档的组织和导航。该组件简化了向 PDF 添加目录的过程,使文档更易于导航和管理。
如何为 PDF 生成目录
要在 PDF 文件中创建目录,请按以下步骤操作:
- 创建
TocOptions 实例以配置目录生成设置。 - 使用
Title 属性设置标题。 - 使用
Headings.Add 方法设计目录标题。 - 使用
AddInput 方法添加输入 PDF 文件。 - 使用
AddOutput 方法指定带目录的输出 PDF 文件。 - 调用
AddTableOfContents 方法生成目录。
1// Create TocOptions object to set instructions
2var options = new TocOptions();
3// Set the Title
4options.Title = "My Table of Contents";
5// Design Headings
6options.Headings.Add(new TocHeading("Introduction", 2));
7options.Headings.Add(new TocHeading("Chapter I", 3));
8options.Headings.Add(new TocHeading("Chapter II", 4));
9options.Headings.Add(new TocHeading("Chapter III", 5));
10// Add input file path
11options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
12// Set output file path
13options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
14// Perform the process
15PdfManager.AddTableOfContents(options);
为 PDF 目录生成书签
可以使用 GenerateBookmarks 属性生成书签。
1// Create TocOptions object to set instructions
2var options = new TocOptions();
3// Set the Title
4options.Title = "My Table of Contents";
5// Generate links in bookmarks
6options.GenerateBookmarks = true;
7// Design Headings
8options.Headings.Add(new TocHeading("Introduction", 2, false, 1));
9options.Headings.Add(new TocHeading("Chapter I", 3, true, 1));
10options.Headings.Add(new TocHeading("Chapter II", 4, true, 1));
11options.Headings.Add(new TocHeading("Example A", 4, true, 2));
12options.Headings.Add(new TocHeading("Example B", 4, true, 2));
13options.Headings.Add(new TocHeading("Example C", 4, true, 2));
14options.Headings.Add(new TocHeading("Example D", 4, true, 2));
15options.Headings.Add(new TocHeading("Chapter III", 5, true, 1));
16// Add input file path
17options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
18// Set output file path
19options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
20// Perform the process
21PdfManager.AddTableOfContents(options);
如何将结果作为流获取
1// Create TocOptions object to set instructions
2var options = new TocOptions();
3// Set the Title
4options.Title = "My Table of Contents";
5// Design Headings
6options.Headings.Add(new TocHeading("Introduction", 2, false, 1));
7// Add input file path
8options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
9// Set output stream
10var outputStream = new MemoryStream();
11options.AddOutput(new StreamData(outputStream));
12options.CloseOutputStreams = false;
13// Perform the process
14PdfManager.AddTableOfContents(options);
自定义目录标题
您可以通过修改 TocHeading 类来自定义目录标题。例如,您可以使用 GenerateNumbering 或手动完成。PageNumber 属性用于页面链接,也可以使用 Level 属性。
1// Create TocOptions object to set instructions
2var heading = new TocHeading();
3heading.Text = "Intro";
4heading.PageNumber = 5;
5heading.GenerateNumbering = true;
6heading.Level = 2;
7var tocOptions = new TocOptions();
8options.Headings.Add(heading);
9// Add input and output files
10tocOptions.AddInput(new FileData("path_to_your_pdf_file.pdf"));
11tocOptions.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
12// Generate the TOC with customized options
13PdfManager.AddTableOfContents(tocOptions);
关键特性
- 动态目录生成:为任何 PDF 文件创建目录,自动根据标题或书签生成条目。
- 自定义:控制目录的外观和结构,包括样式、格式和深度层级。
- 高效工作流:减少手动创建目录所花费的时间,尤其适用于大型或结构复杂的文档。
使用 ChatGPT
Documentize PDF Manager for .NET 插件是一个强大的工具,旨在将 ChatGPT API 与 PDF 应用程序集成。该插件允许开发者基于输入消息生成聊天回复,并将输出保存为 PDF 格式,适用于在 PDF 文档中直接创建对话界面或分析报告。
生成聊天回复
要使用 ChatGPT 插件生成聊天回复并将其保存为 PDF 文件,请按照以下步骤操作:
- 创建
ChatGptRequestOptions 类的实例,以配置请求选项。 - 添加输入和输出 PDF 文件。
- 设置 API 密钥并指定参数,如最大 token 数量和 ChatGPT 模型的查询。
- 运行
CreatePdfByChatGptRequestAsync 方法生成聊天完成内容。
1var options = new ChatGptRequestOptions();
2// Set output file path
3options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
4options.ApiKey = "Your API key."; // You need to provide the key to access the API.
5options.MaxTokens = 1000; // The maximum number of tokens to generate in the chat completion.
6
7// Add the request messages.
8options.Messages.Add(new Message
9{
10 Content = "You are a helpful assistant.",
11 Role = Role.System
12});
13options.Messages.Add(new Message
14{
15 Content = "What is the biggest pizza diameter ever made?",
16 Role = Role.User
17});
18
19// Process the request.
20var result = await PdfManager.CreatePdfByChatGptRequestAsync(options);
21
22var fileResultPath = result.ResultCollection[0].Data;
23var chatCompletionObject = result.ResultCollection[1].Data as ChatCompletion; // The ChatGPT API chat completion object.
添加系统消息和用户消息
为了创建更具交互性的对话,您可以同时添加系统消息和用户消息。这些消息有助于塑造对话上下文。
- 添加系统消息以设定 ChatGPT 的上下文。
- 添加用户消息,代表用户在对话中的输入。
1var options = new ChatGptRequestOptions();
2// Set output file path
3options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
4
5// Add the PDF text source.
6// In case of multiple sources, the text from each document will be added to the request message collection
7// as a separate message with the role "user".
8options.AddInput(new FileData("TextSource.pdf"));
9
10options.ApiKey = "Your API key."; // You need to provide the key to access the API.
11options.MaxTokens = 1000; // The maximum number of tokens to generate in the chat completion.
12
13// Add the request message.
14// In this case, the system message with Content = "You are a helpful assistant." is added by default.
15// The role of the query message is "user" by default.
16options.Query = "How many letters in the provided text?";
17
18// Process the request.
19var result = await PdfManager.CreatePdfByChatGptRequestAsync(options);
20
21var fileResultPath = result.ResultCollection[0].Data;
22var chatCompletionObject = result.ResultCollection[1].Data as ChatCompletion; // The ChatGPT API chat completion object.
关键特性
- Chat 完成:基于自定义输入使用 ChatGPT API 生成回复。
- 系统 & 用户消息:同时提供系统上下文和用户输入,以创建动态对话。
- PDF 输出:将生成的聊天完成内容保存为结构化的 PDF 文件,以便进一步使用。
- 异步处理:通过异步方式处理聊天完成,确保应用程序响应流畅。
PDF Security
使用 Documentize 的 .NET 工具加密 PDF 文件,以保护敏感信息。
使用 Documentize 的 .NET 工具解密您的 PDF 文件,以打开文档。
使用 Documentize 的 .NET 工具对 PDF 文件进行数字签名——轻松实现安全性、真实性和合规性。
PDF Security 的子部分
加密
Documentize PDF Security for .NET 是一个强大的工具,旨在通过提供加密、解密和签名功能来增强 PDF 文档的安全性。它确保您的敏感信息保持机密,并防止未授权访问。
如何加密 PDF
要加密 PDF 文档,请按照以下步骤操作:
- 创建
EncryptOptions 实例,并设置所需的用户密码和所有者密码。 - 使用
AddInput 方法添加输入 PDF 文件。 - 使用
AddOutput 方法添加输出 PDF 文件。 - 使用
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 文档,请按照以下步骤操作:
- 创建
DecryptionOptions 实例,并提供必要的密码。 - 使用
AddInput 方法添加输入 PDF 文件。 - 使用
AddOutput 方法添加输出 PDF 文件。 - 调用
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:
- Instantiate the
SignOptions class with the PFX file path and password. - Add the input PDF and the output file to the options.
- 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.
- Create an instance of
SignOptions. - Set
Visible to false. - Add input and output files.
- 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);
You can use extra options during adding signature to a PFX file like Reason, Contact, Location, PageNumber.
- Instantiate the
SignOptions class with the PFX file path and password. - Add the input PDF and the output file to the options.
- Set values for your options.
- 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:
- Create an instance of
AddTimestampOptions to configure the timestamping process. - Add the input PDF file using the
AddInput method. - Set the output file path using
AddOutput. - 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.
将交互式 PDF 表单转换为不可编辑的文档,使其免受未授权的修改
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.
To flatten form fields in a PDF document, follow these steps:
- Create an instance of the
FlattenFieldsOptions class. - Add the input and output files to the options.
- Call the
Flatten method to perform the flattening operation.
1// Create FlattenFieldsOptions object to set instructions
2var options = new FlattenFieldsOptions();
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
8PdfForm.Flatten(options);
How to Get all Fields in a PDF
You can get information how many fields contains a document.
1// Get Fields Names
2var fieldNames = PdfForm.GetNames(new GetFieldNamesOptions("path_to_your_pdf_file.pdf"));
How to Flatten everything except the first Field in a PDF
You can selectively flatten only specific form fields based on criteria such as the field’s position or name.
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 FileData("path_to_your_pdf_file.pdf"));
6options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
7// Skip 1 field.
8options.SkipFields.Add(fieldNames[0]);
9// Perform the process
10PdfForm.Flatten(options);
Key Features:
- 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。
常见问题解答
此常见问题解答提供有关 Documentize .NET 插件 功能和特性的全面信息,涵盖 PDF 转换、表单处理和目录生成(TOC)等方面。
一般问题
1. 什么是 Documentize for .NET?
Documentize for .NET 是一个强大的库,用于以编程方式管理和处理 PDF 文档。它包括将 PDF 转换为各种格式、编辑 PDF 表单、添加数字签名、生成目录以及确保长期归档的 PDF/A 合规性等功能的插件。
2. 如何安装 Documentize 插件 for .NET?
您可以通过从官方网站下载程序集文件或直接从 NuGet 获取软件包来安装 Documentize 插件。每个插件的文档中提供详细的安装说明。
PDF 转换插件
3. 如何将 PDF 文档转换为 Word(DOC/DOCX)文件?
要使用 PDF 到 DOC 转换器 将 PDF 文档转换为 Word 格式:
- 实例化
PdfDoc 类。 - 创建
PdfToDocOptions 对象以配置转换选项。 - 添加输入 PDF 和输出 DOC/DOCX 文件路径。
- 调用
Process 方法执行转换。
4. 如何将 PDF 页转换为 JPEG 图像?
使用 PDF 到 JPEG 转换器:
- 创建
Jpeg 类的实例。 - 通过
JpegOptions 设置转换选项(例如,分辨率,页面范围)。 - 添加输入/输出文件路径。
- 调用
Jpeg.Process 方法运行转换。
5. 如何将 PDF 转换为 PNG?
要将 PDF 转换为 PNG 格式:
- 创建
Png 类的实例和 PngOptions 对象。 - 添加输入 PDF 并指定输出文件夹。
- 设置选项,如分辨率(例如,300 DPI)。
- 调用
Process 方法生成 PNG 图像。
6. 如何将 PDF 转换为 Excel(XLS/XLSX)?
要将 PDF 转换为 Excel:
- 实例化
PdfXls 类。 - 使用
PdfToXlsOptions 配置输入/输出路径和转换选项。 - 调用
Process 方法开始转换。
7. 如何将 PDF 转换为 HTML?
要将 PDF 文档转换为 HTML:
- 创建
PdfHtml 类的实例。 - 使用
PdfToHtmlOptions 或 HtmlToPdfOptions 配置转换选项。 - 添加输入/输出路径并调用
Process 方法。
PDF 表单处理
8. 如何使用表单编辑器编辑 PDF 表单?
PDF 表单编辑器 提供以下功能:
- 添加字段(
FormEditorAddOptions)。 - 更新字段(
FormEditorSetOptions)。 - 删除字段(
FormRemoveSelectedFieldsOptions)。
配置表单字段后,运行 Process 方法。
9. 如何扁平化 PDF 表单?
要扁平化表单字段:
- 实例化
FormFlattener 类。 - 使用
FormFlattenAllFieldsOptions 扁平化所有字段或使用 FormFlattenSelectedFieldsOptions 定位特定字段。 - 添加输入/输出文件并调用
Process 方法。
10. 如何导出 PDF 表单中的数据?
要导出表单数据,请使用 PDF 表单导出器。创建 FormExporterValuesToCsvOptions 对象,指定表单字段条件,并运行 Process 方法将数据导出为 CSV 格式。
PDF/A 和 TOC 管理
11. 如何将 PDF 转换为 PDF/A 格式?
要将 PDF 转换为 PDF/A:
- 使用
PdfAConverter 类。 - 在
PdfAConvertOptions 中配置 PDF/A 版本(例如,PDF/A-3B)。 - 添加输入/输出路径并调用
Process 方法。
12. 如何在 PDF 中生成目录(TOC)?
要创建 TOC:
- 创建
TocGenerator 类的实例。 - 使用
TocOptions 定义 TOC 参数。 - 添加输入/输出文件并运行
Process 方法。
签名处理
13. 如何对 PDF 文档进行数字签名?
要添加数字签名:
- 实例化
Signature 类。 - 使用
SignOptions 配置 PFX 文件、密码和签名详细信息(例如,原因、联系信息)。 - 添加输入/输出文件并运行
Process 方法。
附加功能
14. 我可以使用 Documentize 拆分 PDF 文件吗?
可以,使用 PDF 拆分器:
- 实例化
Splitter 类。 - 使用
SplitOptions 配置拆分选项。 - 添加输入/输出路径并调用
Process 方法。
15. 如何将多个 PDF 文件合并为一个?
要合并 PDF:
- 实例化
Merger 类。 - 添加输入 PDF,并通过
MergeOptions 指定输出文件。 - 运行
Process 方法合并文件。
16. Documentize 是否仅限于处理 PDF?
虽然 Documentize 主要专注于 PDF 操作,但它也支持与 DOC、XLS、HTML、JPEG 和 PNG 等格式之间的转换。
许可和兼容性
17. 使用 Documentize 插件的系统要求是什么?
Documentize 支持:
- 操作系统:Windows 7-11,Windows Server 2003-2022,macOS(10.12+),以及 Linux。
- 框架:.NET Framework 4.0 至 8.0。
- IDE:与各种版本的 Visual Studio 兼容。
18. 如何设置 Documentize 的许可证密钥?
要激活插件,请在项目中引用 Documentize 并在调用任何方法之前设置许可证密钥。有关详细说明,请参考特定插件的文档。
19. 在哪里可以找到更多 Documentize 插件的示例和文档?
完整的 API 文档和示例可以在 Documentize 网站上找到,或通过您开发环境中的 NuGet 包获取。