PDF Manager

Merge PDF

Merge PDFs easily with Documentize's .NET tools—combine multiple files into one while preserving quality and structure.

Split PDF

Split PDFs effortlessly with Documentize's .NET tools—extract pages, create new files, and manage documents with precision

Optimize PDF

Optimize your PDFs effortlessly with Documentize's .NET tools—reduce file size, enhance performance, and maintain quality

Add Table

Generate professional PDF tables with Documentize's .NET tools—customize layouts, styles, and data with ease.

Add TOC

Enhance the organization and navigation of PDF documents by dynamically generating a Table of Contents (TOC)

Use ChatGPT

Enhance your PDFs with AI using Documentize's ChatGPT integration—generate, edit, and analyze content intelligently.

Subsections of PDF Manager

Merge PDF

The Documentize PDF Manager for .NET is a versatile tool designed to merge multiple PDF documents into a single file. It simplifies the consolidation of PDF files, ensuring your documents are merged efficiently and maintaining consistency across content. The plugin handles internal resources such as fonts and images to optimize the merged document.

How to Merge PDF

To merge multiple PDF documents into a single file, follow these steps:

  1. Create an instance of MergeOptions to configure the merging process.
  2. Add input PDF files using the AddInput method.
  3. Add output PDF file using AddOutput method.
  4. Execute the merge using the Merge method of PdfManager class.
1// Create MergeOptions object to set instructions
2var options = new MergeOptions();
3// Add input file paths
4options.AddInput(new FileDataSource("path_to_your_pdf_file_1.pdf"));
5options.AddInput(new FileDataSource("path_to_your_pdf_file_2.pdf"));
6// Set output file path
7options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
8// Perform the process
9PdfManager.Merge(options);

Key Features:

  • Merge Multiple PDFs: Easily combine multiple PDF files into one.
  • Resource Optimization: Removes duplicate fonts and images during merging.
  • Batch Processing: Merge large batches of PDF documents in one go.

Split PDF

The Documentize PDF Manager for .NET is a powerful tool that simplifies the process of splitting large PDF documents into smaller, more manageable files. Whether you need to extract individual pages or divide a document into specific sections, this plugin allows you to achieve it efficiently and with minimal effort.

How to Split PDF

To split a PDF document into individual pages, follow these steps:

  1. Create an instance of SplitOptions to configure the splitting options.
  2. Add the input PDF file using the AddInput method.
  3. Add output files for each split page using the AddOutput method.
  4. Run the Split method in the PdfManager class to split the document.
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 FileDataSource("path_to_result_pdf_file_1.pdf"));
7options.AddOutput(new FileDataSource("path_to_result_pdf_file_2.pdf"));
8// Perform the process
9PdfManager.Split(options);

Key Features:

  • Split PDF by Page: Break down a PDF document into individual pages.
  • Custom Split Options: Configure the splitting process based on your requirements.
  • Organized Output: Easily manage the output files for each split page or section.

Optimize PDF

The Documentize PDF Manager for .NET is a comprehensive plugin that enhances PDF documents through advanced optimization techniques. It is designed to help reduce file sizes, rotate pages, crop content, and resize documents. These operations improve the quality and manageability of PDF files, making them easier to store, share, and view.

Optimize PDF

The following steps demonstrate how to optimize a PDF document by reducing its file size while maintaining quality.

  1. Create an OptimizeOptions object to configure optimization settings.
  2. Add input PDF file(s) and set an output location for the optimized file.
  3. Run the Optimize method of PdfManager to execute the optimization.
1// Create OptimizeOptions object to set instructions
2var options = new OptimizeOptions();
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
8PdfManager.Optimize(options);

Rotate PDF

Use the RotateOptions class to adjust the orientation of pages in a PDF file.

  1. Create a RotateOptions object and configure the rotation angle.
  2. Add the input PDF file and specify the output file location.
  3. Set the rotation angle (e.g., 90 degrees) using the SetRotation method.
  4. Run the Rotate method of PdfManager.
 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 FileDataSource("path_to_your_pdf_file.pdf"));
 7// Set output file path
 8options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
 9// Perform the process
10PdfManager.Rotate(options);

Resize PDF

To resize a PDF document, the ResizeOptions class is used to specify the new page size for the document.

  1. Create a ResizeOptions object to define the page size.
  2. Add the input file and set the desired output location.
  3. Use the SetPageSize method to specify the new size (e.g., A4).
  4. Run the Resize method of PdfManager.
 1// Create ResizeOptions object to set instructions
 2var options = new ResizeOptions();
 3// Set new PageSize
 4options.PageSize = PageSize.A3;
 5// Add input file path
 6options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
 7// Set output file path
 8options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
 9// Perform the process
10PdfManager.Resize(options);

Compress PDF

Compress PDF document when feasible by eliminating unused page resources, merging identical assets, and discarding redundant objects.

  1. Create an CompressOptions object to configure optimization settings.
  2. Add the input file and specify the output file location.
  3. Use the SetCropBox method to define the crop area.
  4. Run the Compress method of PdfManager.
1// Create CompressOptions object to set instructions
2var options = new CompressOptions();
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
8PdfManager.Compress(options);

Key Features:

  • Optimization: Reduce PDF file size without losing quality.
  • Rotation: Adjust the orientation of PDF pages.
  • Resizing: Resize pages to specific dimensions (e.g., A4, Letter).
  • Compressing: Remove unused page resources and objects from the document.

Add Table

The Documentize PDF Manager for .NET is a versatile plugin designed to streamline the integration of tables into PDF documents. Whether you’re organizing data, designing forms, or improving document readability, this plugin simplifies the process while maintaining precision and efficiency. Its intuitive API supports both single document and batch processing workflows, making it an essential tool for developers working with structured data.

Creating a PDF with Tables

Follow these steps to create structured tables in a PDF using the TableOptions class:

  1. Configure the TableOptions object to define table structure, content, and input/output files.
  2. Add tables, rows, and cells to your PDF.
  3. Finalize the table generation process using the AddTable method.

Here’s an example:

 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 FileDataSource("path_to_input.pdf"));
25// Set output file path
26options.AddOutput(new FileDataSource("path_to_output.pdf"));
27// Perform the process
28PdfManager.AddTable(options);

Set page of the table

Follow these steps to create table in a PDF after 2 page: Here’s an example:

 1var options = new TableOptions();
 2options.InsertPageBefore(2) // Add table before page 2
 3   .AddTable()
 4        .AddRow()
 5            .AddCell().AddParagraph("Name")
 6            .AddCell().AddParagraph("Age")
 7// Add input file path
 8options.AddInput(new FileDataSource("path_to_input.pdf"));
 9// Set output file path
10options.AddOutput(new FileDataSource("path_to_output.pdf"));
11// Perform the process
12PdfManager.AddTable(options);

Key Features:

  • Dynamic Table Creation: Effortlessly generate structured tables in PDF documents.
  • Page Placement: Insert tables at specific locations within a PDF with precision.
  • Customizable Layout: Adjust table structure, cell alignment, and styling.

Add TOC

The Documentize PDF Manager for .NET is a powerful plugin designed to enhance the organization and navigation of PDF documents by dynamically generating a Table of Contents (TOC). This plugin simplifies the process of adding TOCs to your PDFs, making documents easier to navigate and manage.

How to Generate a TOC for a PDF

To create a Table of Contents in a PDF file, follow these steps:

  1. Create an instance of TocOptions to configure TOC generation settings.
  2. Set a Title using the Title property.
  3. Design Headings of TOC using the Headings.Add method.
  4. Add the input PDF file using the AddInput method.
  5. Specify the output PDF file with the TOC using the AddOutput method.
  6. Call the AddTableOfContents method to generate the TOC.
 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 FileDataSource("path_to_your_pdf_file.pdf"));
12// Set output file path
13options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
14// Perform the process
15PdfManager.AddTableOfContents(options);

Generate bookmarks in a TOC for a PDF

You can use ‘GenerateBookmarks’ property for bookmarks generation.

 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 FileDataSource("path_to_your_pdf_file.pdf"));
18// Set output file path
19options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
20// Perform the process
21PdfManager.AddTableOfContents(options);

How to get Result as Stream

 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 FileDataSource("path_to_your_pdf_file.pdf"));
 9// Set output stream 
10var outputStream = new MemoryStream();
11options.AddOutput(new StreamDataSource(outputStream));
12options.CloseOutputStreams = false;
13// Perform the process
14PdfManager.AddTableOfContents(options);

Customizing the TOC Heading

You can customize the Table of Contents Heading by modifying the TocHeading class. For example, you can use ‘GenerateNumbering’ or done it manually. Property ‘PageNumber’ used for links on pages. Also you can use Level property.

 1var heading = new TocHeading();
 2heading.Text = "Intro";
 3heading.PageNumber = 5;
 4heading.GenerateNumbering = true;
 5heading.Level = 2;
 6
 7var tocOptions = new TocOptions();
 8options.Headings.Add(heading);
 9// Add input and output files
10tocOptions.AddInput(new FileDataSource(@"C:\Samples\input.pdf"));
11tocOptions.AddOutput(new FileDataSource(@"C:\Samples\output_with_toc.pdf"));
12
13// Generate the TOC with customized options
14PdfManager.AddTableOfContents(tocOptions);

Key Features:

  • Dynamic TOC Generation: Create a TOC for any PDF file with automatically generated entries based on headings or bookmarks.
  • Customization: Control the appearance and structure of the TOC, including styles, formatting, and levels of depth.
  • Efficient Workflow: Minimize time spent manually creating TOCs, especially for large or complex documents.

Use ChatGPT

The Documentize PDF Manager for .NET plugin is a powerful tool designed to integrate the ChatGPT API with PDF applications. This plugin allows developers to generate chat responses based on input messages and save the output in PDF format, making it suitable for creating conversational interfaces or analysis reports directly within PDF documents.

Generate Chat Responses

To generate chat responses and save them to a PDF file using the ChatGPT plugin, follow these steps:

  1. Create an instance of the ChatGptRequestOptions class to configure the request options.
  2. Add input and output PDF files.
  3. Set the API key and specify parameters such as maximum token count and the query for the ChatGPT model.
  4. Run the CreatePdfByChatGptRequestAsync method to generate the chat completion.
 1var options = new ChatGptRequestOptions();
 2// Set output file path
 3options.AddOutput(new FileDataSource("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.

Adding System and User Messages

To create a more interactive conversation, you can add both system and user messages. These messages help shape the conversation context.

  1. Add a system message that sets the context for ChatGPT.
  2. Add a user message that represents the user’s input for the conversation.
 1var options = new ChatGptRequestOptions();
 2// Set output file path
 3options.AddOutput(new FileDataSource("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 FileDataSource("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.

Key Features:

  • Chat Completions: Generate responses using the ChatGPT API based on custom input.
  • System & User Messages: Provide both system context and user input to create dynamic conversations.
  • PDF Output: Save generated chat completions in a structured PDF file for further use.
  • Asynchronous Processing: Ensure responsive applications by processing chat completions asynchronously.
 English