Class PdfManager
Представляет плагин Documentize.PdfManager. Используется для объединения, разделения, оптимизации, вращения, изменения размера, сжатия PDF‑документов и добавления таблицы, добавления оглавления (TOC) в PDF‑документы. Может объединять несколько PDF‑документов в один PDF. Может разделять PDF‑документы на отдельные страницы. Может оптимизировать, вращать, изменять размер, сжимать PDF‑документы. Может вращать, изменять размер страниц PDF‑документа. Может добавлять таблицу в PDF‑документ. Может добавлять оглавление в PDF‑документ.
Представляет плагин Documentize.PdfManager. Используется для объединения, разделения, оптимизации, вращения, изменения размера, сжатия PDF‑документов и добавления таблицы, добавления оглавления (TOC) в PDF‑документы.
Может объединять несколько PDF‑документов в один PDF.
Может разделять PDF‑документы на отдельные страницы.
Может оптимизировать, вращать, изменять размер, сжимать PDF‑документы.
Может вращать, изменять размер страниц PDF‑документа.
Может добавлять таблицу в PDF‑документ.
Может добавлять оглавление в PDF‑документ.
public static class PdfManagerInheritance
Inherited Members
- object.GetType(),
- object.MemberwiseClone(),
- object.ToString(),
- object.Equals(object?),
- object.Equals(object?, object?),
- object.ReferenceEquals(object?, object?),
- object.GetHashCode()
Примеры
The example demonstrates how to Merge two PDF documents.
// Create MergeOptions object to set instructions
var options = new MergeOptions();
// Add input file paths
options.AddInput(new FileData("path_to_your_pdf_file_1.pdf"));
options.AddInput(new FileData("path_to_your_pdf_file_2.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.Merge(options);The example demonstrates how to Split PDF document.
// Create SplitOptions object to set instructions
var options = new SplitOptions();
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file paths
options.AddOutput(new FileData("path_to_result_pdf_file_1.pdf"));
options.AddOutput(new FileData("path_to_result_pdf_file_2.pdf"));
// Perform the process
PdfManager.Split(options);The example demonstrates how to Optimize PDF document.
// Create OptimizeOptions object to set instructions
var options = new OptimizeOptions();
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.Optimize(options);The example demonstrates how to Rotate PDF document.
// Create RotateOptions object to set instructions
var options = new RotateOptions();
// Set new Rotation
options.Rotation = Rotation.On90;
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.Rotate(options);The example demonstrates how to Resize PDF document.
// Create ResizeOptions object to set instructions
var options = new ResizeOptions();
// Set new PageSize
options.PageSize = PageSize.A3;
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.Resize(options);The example demonstrates how to Compress PDF document.
// Create CompressOptions object to set instructions
var options = new CompressOptions();
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.Compress(options);The example demonstrates how to Add Table to PDF file.
// Configure table options
var options = new TableOptions();
options.InsertPageBefore(1)
.AddTable()
.AddRow()
.AddCell().AddParagraph("Name")
.AddCell().AddParagraph("Age")
.AddRow()
.AddCell().AddParagraph("Bob")
.AddCell().AddParagraph("12")
.AddRow()
.AddCell().AddParagraph("Sam")
.AddCell().AddParagraph("20")
.AddRow()
.AddCell().AddParagraph("Sandy")
.AddCell().AddParagraph("26")
.AddRow()
.AddCell().AddParagraph("Tom")
.AddCell().AddParagraph("12")
.AddRow()
.AddCell().AddParagraph("Jim")
.AddCell().AddParagraph("27");
// Add input file path
options.AddInput(new FileData("path_to_input.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_output.pdf"));
// Perform the process
PdfManager.AddTable(options);The example demonstrates how to add Table of Contents to PDF file.
// Create TocOptions object to set instructions
var options = new TocOptions();
// Set the Title
options.Title = "My Table of Contents";
// Design Headings
options.Headings.Add(new TocHeading("Introduction", 2));
options.Headings.Add(new TocHeading("Chapter I", 3));
options.Headings.Add(new TocHeading("Chapter II", 4));
options.Headings.Add(new TocHeading("Chapter III", 5));
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.AddTableOfContents(options);The example demonstrates how to add Table of Contents to PDF file with generating bookmarks.
// Create TocOptions object to set instructions
var options = new TocOptions();
// Set the Title
options.Title = "My Table of Contents";
// Generate links in bookmarks
options.GenerateBookmarks = true;
// Design Headings
options.Headings.Add(new TocHeading("Introduction", 2, false, 1));
options.Headings.Add(new TocHeading("Chapter I", 3, true, 1));
options.Headings.Add(new TocHeading("Chapter II", 4, true, 1));
options.Headings.Add(new TocHeading("Example A", 4, true, 2));
options.Headings.Add(new TocHeading("Example B", 4, true, 2));
options.Headings.Add(new TocHeading("Example C", 4, true, 2));
options.Headings.Add(new TocHeading("Example D", 4, true, 2));
options.Headings.Add(new TocHeading("Chapter III", 5, true, 1));
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.AddTableOfContents(options);The example demonstrates how to add Table of Contents to PDF file and save as stream.
// Create TocOptions object to set instructions
var options = new TocOptions();
// Set the Title
options.Title = "My Table of Contents";
// Design Headings
options.Headings.Add(new TocHeading("Introduction", 2, false, 1));
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output stream
var outputStream = new MemoryStream();
options.AddOutput(new StreamData(outputStream));
options.CloseOutputStreams = false;
// Perform the process
PdfManager.AddTableOfContents(options);The example demonstrates how to use ChatGpt by adding messages to the request.
var options = new ChatGptRequestOptions();
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
options.ApiKey = "Your API key."; // You need to provide the key to access the API.
options.MaxTokens = 1000; // The maximum number of tokens to generate in the chat completion.
// Add the request messages.
options.Messages.Add(new Message
{
Content = "You are a helpful assistant.",
Role = Role.System
});
options.Messages.Add(new Message
{
Content = "What is the biggest pizza diameter ever made?",
Role = Role.User
});
// Process the request.
var result = await PdfManager.CreatePdfByChatGptRequestAsync(options);
var fileResultPath = result.ResultCollection[0].Data;
var chatCompletionObject = result.ResultCollection[1].Data as ChatCompletion; // The ChatGPT API chat completion object.The example demonstrates how to use ChatGpt by adding one message to the request.
var options = new ChatGptRequestOptions();
options.AddOutput(new FileData("path_to_result_pdf_file.pdf")); // Add the output file path.
options.ApiKey = "Your API key."; // You need to provide the key to access the API.
options.MaxTokens = 1000; // The maximum number of tokens to generate in the chat completion.
// Add the request message.
// In this case, the system message with Content = "You are a helpful assistant." is added by default.
// The role of the query message is "user" by default.
options.Query = "What is the lowest temperature recorded on the Earth?";
// Process the request.
var result = await PdfManager.CreatePdfByChatGptRequestAsync(options);
var fileResultPath = result.ResultCollection[0].Data;
var chatCompletionObject = result.ResultCollection[1].Data as ChatCompletion; // The ChatGPT API chat completion object.The example demonstrates how to use Chat by adding file(s) as the message source(s).
var options = new ChatGptRequestOptions();
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Add the PDF text source.
// In case of multiple sources, the text from each document will be added to the request message collection
// as a separate message with the role "user".
options.AddInput(new FileData("TextSource.pdf"));
options.ApiKey = "Your API key."; // You need to provide the key to access the API.
options.MaxTokens = 1000; // The maximum number of tokens to generate in the chat completion.
// Add the request message.
// In this case, the system message with Content = "You are a helpful assistant." is added by default.
// The role of the query message is "user" by default.
options.Query = "How many letters in the provided text?";
// Process the request.
var result = await PdfManager.CreatePdfByChatGptRequestAsync(options);
var fileResultPath = result.ResultCollection[0].Data;
var chatCompletionObject = result.ResultCollection[1].Data as ChatCompletion; // The ChatGPT API chat completion object.Методы
AddTable(TableOptions)
Add Table to PDF document.
public static ResultContainer AddTable(TableOptions options)Parameters
optionsTableOptions: Объект опций, содержащий инструкции для операции.
Returns
ResultContainer : Объект, содержащий результат операции.
Exceptions
Если параметры не заданы.
AddTableOfContents(TocOptions)
Add Table of Contents (TOC) to PDF document.
public static ResultContainer AddTableOfContents(TocOptions options)Parameters
optionsTocOptions: Объект опций, содержащий инструкции для операции.
Returns
ResultContainer : Объект, содержащий результат операции.
Exceptions
Если параметры не заданы.
Compress(CompressOptions)
Compress PDF document. Try to reduce size of the document.
public static ResultContainer Compress(CompressOptions options)Parameters
optionsCompressOptions: Объект опций, содержащий инструкции для операции.
Returns
ResultContainer : Объект, содержащий результат операции.
Exceptions
Если параметры не заданы.
CreatePdfByChatGptRequestAsync(ChatGptRequestOptions)
Create PDF document by Reply of ChatGpt. Used to send requests to ChatGPT directly or by adding PDF file sources and save the reply to the output source.
public static Task<resultcontainer> CreatePdfByChatGptRequestAsync(ChatGptRequestOptions options)Parameters
optionsChatGptRequestOptions: Объект опций, содержащий инструкции для операции.
Returns
Объект, содержащий результат операции.
Exceptions
ArgumentException : Если параметры не заданы.
Merge(MergeOptions)
Merge PDF documents.
public static ResultContainer Merge(MergeOptions options)Parameters
optionsMergeOptions: Объект опций, содержащий инструкции для операции.
Returns
ResultContainer : Объект, содержащий результат операции.
Exceptions
Если параметры не заданы.
Optimize(OptimizeOptions)
Optimize PDF document. Linearize the document in order to
- open the first page as quickly as possible;
- display next page or follow by link to the next page as quickly as possible;
- display the page incrementally as it arrives when data for a page is delivered over a slow channel (display the most useful data first);
- permit user interaction, such as following a link, to be performed even before the entire page has been received and displayed.
public static ResultContainer Optimize(OptimizeOptions options)Parameters
optionsOptimizeOptions: Объект опций, содержащий инструкции для операции.
Returns
ResultContainer : Объект, содержащий результат операции.
Exceptions
Если параметры не заданы.
Resize(ResizeOptions)
Resize Pages of PDF document.
public static ResultContainer Resize(ResizeOptions options)Parameters
optionsResizeOptions: Объект опций, содержащий инструкции для операции.
Returns
ResultContainer : Объект, содержащий результат операции.
Exceptions
Если параметры не заданы.
Rotate(RotateOptions)
Rotate Pages of PDF document.
public static ResultContainer Rotate(RotateOptions options)Parameters
optionsRotateOptions: Объект опций, содержащий инструкции для операции.
Returns
ResultContainer : Объект, содержащий результат операции.
Exceptions
Если параметры не заданы.
Split(SplitOptions)
Split PDF document by pages.
public static ResultContainer Split(SplitOptions options)Parameters
optionsSplitOptions: Объект опций, содержащий инструкции для операции.
Returns
ResultContainer : Объект, содержащий результат операции.
Exceptions
Если параметры не заданы.
Namespace: Documentize Assembly: Documentize.dll