Class PdfManager
Documentize.PdfManager コンポーネントを表します。PDF ドキュメントの統合、分割、最適化、回転、リサイズ、圧縮、テーブル追加、目次追加に使用できます。複数の PDF ドキュメントを単一の PDF に統合できます。PDF ドキュメントを個別のページに分割できます。PDF ドキュメントを最適化、回転、リサイズ、圧縮できます。PDF ドキュメントのページを回転、リサイズできます。PDF ドキュメントにテーブルを追加できます。PDF ドキュメントに目次を追加できます。
Documentize.PdfManager コンポーネントを表します。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()
Methods
AddTable(TableOptions)
PDF ドキュメントにテーブルを追加します。
public static ResultContainer AddTable(TableOptions options)Parameters
optionsTableOptions: 操作の指示を含むオプション オブジェクト。
Returns
ResultContainer : 操作の結果を含むオブジェクト。
Examples
この例は PDF ファイルにテーブルを追加する方法を示しています。
// 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);この例は 2 ページの前にテーブルを追加する方法を示しています。
// Configure table options
var options = new TableOptions();
options.InsertPageBefore(2) // Add table before page 2
.AddTable()
.AddRow()
.AddCell().AddParagraph("Name")
.AddCell().AddParagraph("Age");
// 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);Exceptions
オプションが設定されていない場合。
AddTableOfContents(TocOptions)
PDF ドキュメントに目次 (TOC) を追加します。
public static ResultContainer AddTableOfContents(TocOptions options)Parameters
optionsTocOptions: 操作の指示を含むオプション オブジェクト。
Returns
ResultContainer : 操作の結果を含むオブジェクト。
Examples
この例は PDF ファイルに目次を追加する方法を示しています。
// 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);この例はブックマークを生成しながら PDF ファイルに目次を追加する方法を示しています。
// 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);この例は PDF ファイルに目次を追加し、ストリームとして保存する方法を示しています。
// 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);この例は目次の見出しをカスタマイズして PDF ファイルに目次を追加する方法を示しています。
// Create TocOptions object to set instructions
var heading = new TocHeading();
heading.Text = "Intro";
heading.PageNumber = 5;
heading.GenerateNumbering = true;
heading.Level = 2;
var tocOptions = new TocOptions();
tocOptions.Headings.Add(heading);
// Add input and output files
tocOptions.AddInput(new FileData("path_to_your_pdf_file.pdf"));
tocOptions.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Generate the TOC with customized options
PdfManager.AddTableOfContents(tocOptions);Exceptions
オプションが設定されていない場合。
Compress(CompressOptions)
PDF ドキュメントを圧縮します。サイズ削減を試みます。
public static ResultContainer Compress(CompressOptions options)Parameters
optionsCompressOptions: 操作の指示を含むオプション オブジェクト。
Returns
ResultContainer : 操作の結果を含むオブジェクト。
Examples
この例は PDF ドキュメントを圧縮する方法を示しています。
// 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);Exceptions
オプションが設定されていない場合。
CreatePdfByChatGptRequestAsync(ChatGptRequestOptions)
ChatGpt の応答から PDF ドキュメントを作成します。ChatGPT への直接リクエスト、または PDF ファイル ソースを追加して応答を出力ソースに保存するために使用します。
public static Task<resultcontainer> CreatePdfByChatGptRequestAsync(ChatGptRequestOptions options)Parameters
optionsChatGptRequestOptions: 操作の指示を含むオプション オブジェクト。
Returns
操作の結果を含むオブジェクト。
Examples
この例はメッセージをリクエストに追加して ChatGpt を使用する方法を示しています。
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.この例はリクエストに 1 件のメッセージだけを追加して ChatGpt を使用する方法を示しています。
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.この例はファイルをメッセージ ソースとして追加して Chat を使用する方法を示しています。
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.Exceptions
ArgumentException : If options not set.
Merge(MergeOptions)
PDF ドキュメントを統合します。
public static ResultContainer Merge(MergeOptions options)Parameters
optionsMergeOptions: 操作の指示を含むオプション オブジェクト。
Returns
ResultContainer : 操作の結果を含むオブジェクト。
Examples
この例は 2 つの PDF ドキュメントを統合する方法を示しています。
// 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);Exceptions
オプションが設定されていない場合。
Optimize(OptimizeOptions)
PDF ドキュメントを最適化します。 ドキュメントをリニアライズし、
- 最初のページをできるだけ早く開く、
- 次のページや次ページへのリンクをできるだけ早く表示する、
- ページデータが遅いチャネルで届くときに、ページを段階的に表示し(最も有用なデータを先に表示)、
- ページ全体が受信・表示される前でも、リンクをたどるといったユーザー操作を可能にする ことができます。
public static ResultContainer Optimize(OptimizeOptions options)Parameters
optionsOptimizeOptions: 操作の指示を含むオプション オブジェクト。
Returns
ResultContainer : 操作の結果を含むオブジェクト。
Examples
この例は PDF ドキュメントを最適化する方法を示しています。
// 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);Exceptions
オプションが設定されていない場合。
Resize(ResizeOptions)
PDF ドキュメントのページをリサイズします。
public static ResultContainer Resize(ResizeOptions options)Parameters
optionsResizeOptions: 操作の指示を含むオプション オブジェクト。
Returns
ResultContainer : 操作の結果を含むオブジェクト。
Examples
この例は PDF ドキュメントをリサイズする方法を示しています。
// 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);Exceptions
オプションが設定されていない場合。
Rotate(RotateOptions)
PDF ドキュメントのページを回転します。
public static ResultContainer Rotate(RotateOptions options)Parameters
optionsRotateOptions: 操作の指示を含むオプション オブジェクト。
Returns
ResultContainer : 操作の結果を含むオブジェクト。
Examples
この例は PDF ドキュメントを回転する方法を示しています。
// 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);Exceptions
オプションが設定されていない場合。
Split(SplitOptions)
PDF ドキュメントをページごとに分割します。
public static ResultContainer Split(SplitOptions options)Parameters
optionsSplitOptions: 操作の指示を含むオプション オブジェクト。
Returns
ResultContainer : 操作の結果を含むオブジェクト。
Examples
この例は PDF ドキュメントを分割する方法を示しています。
// 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);Exceptions
オプションが設定されていない場合。
Namespace: Documentize Assembly: Documentize.dll