PDF Manager

合并 PDF

使用 Documentize 的 .NET 工具轻松合并 PDF——将多个文件合并为一个,同时保持质量和结构。

拆分 PDF

使用 Documentize 的 .NET 工具轻松拆分 PDF —— 提取页面、创建新文件,并精准管理文档

调整 PDF 页面大小

轻松使用 Documentize PDF Manager 调整 PDF 文档的页面大小

旋转 PDF 页面

轻松使用 Documentize PDF Manager 旋转 PDF 文档的页面

压缩 PDF

使用 Documentize PDF Manager 轻松压缩您的 PDF 文档

优化 PDF

使用 Documentize 的 .NET 工具轻松优化 PDF——减小文件大小,提高性能,同时保持质量

Add Table

使用 Documentize 的 .NET 工具生成专业的 PDF 表格——轻松自定义布局、样式和数据。

添加目录

通过动态生成目录(TOC)来增强 PDF 文档的组织和导航

使用 ChatGPT

使用 Documentize 的 ChatGPT 集成,通过 AI 增强您的 PDF——智能生成、编辑和分析内容。

PDF Manager 的子部分

合并 PDF

Documentize PDF Manager for .NET 是一款多功能工具,旨在将多个 PDF 文档合并为单个文件。它简化了 PDF 文件的整合过程,确保文档高效合并并在内容上保持一致性。该组件会处理字体、图像等内部资源,以优化合并后的文档。

如何合并 PDF

将多个 PDF 文档合并为单个文件,请按以下步骤操作:

  1. 创建 MergeOptions 实例以配置合并过程。
  2. 使用 AddInput 方法添加输入 PDF 文件。
  3. 使用 AddOutput 方法添加输出 PDF 文件。
  4. 调用 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 文档拆分为单独的页面,请按以下步骤操作:

  1. 创建 SplitOptions 实例以配置拆分选项。
  2. 使用 AddInput 方法添加输入 PDF 文件。
  3. 使用 AddOutput 方法为每个拆分页面添加输出文件。
  4. 调用 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 类来指定文档的新页面大小。

  1. 创建一个 ResizeOptions 对象以定义页面尺寸。
  2. 添加输入文件并设置期望的输出位置。
  3. 使用 SetPageSize 方法指定新的尺寸(例如 A4)。
  4. 调用 PdfManagerResize 方法。
 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 文件中页面的方向。

  1. 创建 RotateOptions 对象并配置旋转角度。
  2. 添加输入 PDF 文件并指定输出文件位置。
  3. 使用 SetRotation 方法设置旋转角度(例如,90 度)。
  4. 运行 PdfManagerRotate 方法。
 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);

关键特性:

  • Rotation:调整 PDF 页面方向。

压缩 PDF

The PDF Manager 是一个综合工具,通过高级优化技术提升 PDF 文档。这些操作压缩 PDF 文档,使其更易于存储、分享和查看。

压缩 PDF

在可行的情况下,通过消除未使用的页面资源、合并相同的资产以及丢弃冗余对象来压缩 PDF 文档。

  1. 创建一个 CompressOptions 对象以配置优化设置。
  2. 添加输入文件并指定输出文件位置。
  3. 使用 SetCropBox 方法定义裁剪区域。
  4. 运行 PdfManagerCompress 方法。
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 文档。

  1. 创建一个 OptimizeOptions 对象以配置优化设置。
  2. 添加输入 PDF 文件并设置优化后文件的输出位置。
  3. 调用 PdfManagerOptimize 方法执行优化。
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 中创建结构化表格:

  1. 配置 TableOptions 对象,以定义表格结构、内容以及输入/输出文件。
  2. 向 PDF 添加表格、行和单元格。
  3. 使用 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 文件中创建目录,请按以下步骤操作:

  1. 创建 TocOptions 实例以配置目录生成设置。
  2. 使用 Title 属性设置标题。
  3. 使用 Headings.Add 方法设计目录标题。
  4. 使用 AddInput 方法添加输入 PDF 文件。
  5. 使用 AddOutput 方法指定带目录的输出 PDF 文件。
  6. 调用 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 文件,请按照以下步骤操作:

  1. 创建 ChatGptRequestOptions 类的实例,以配置请求选项。
  2. 添加输入和输出 PDF 文件。
  3. 设置 API 密钥并指定参数,如最大 token 数量和 ChatGPT 模型的查询。
  4. 运行 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.

添加系统消息和用户消息

为了创建更具交互性的对话,您可以同时添加系统消息和用户消息。这些消息有助于塑造对话上下文。

  1. 添加系统消息以设定 ChatGPT 的上下文。
  2. 添加用户消息,代表用户在对话中的输入。
 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 文件,以便进一步使用。
  • 异步处理:通过异步方式处理聊天完成,确保应用程序响应流畅。
 中文