v25.10

新しいプラグイン PDF Extractor

  • Class PdfExtractor: プラグインのすべての機能(TextExtractor、ImageExtractor、FormExporter)を含みます。
  • Class TextExtractor: まもなく削除されます。PdfExtractor を使用してください。
  • Class ImageExtractor: まもなく削除されます。PdfExtractor を使用してください。
  • Class FormExporter: まもなく削除されます。PdfExtractor を使用してください。
  • Class TextExtractorOptions: Class ExtractTextOptions に名前が変更されました。
  • Class ImageExtractorOptions: Class ExtractImagesOptions に名前が変更されました。
  • Class FormExportToDsvOptions: Class ExtractFormDataToDsvOptions に名前が変更されました。
  • 詳細は The New Plugin Architecture を参照してください。

使用例:

PDF ドキュメントからテキストコンテンツを抽出する例です。

// Create ExtractTextOptions object to set instructions
var options = new ExtractTextOptions();
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Perform the process
var results = PdfExtractor.ExtractText(options);
// Get the extracted text from the ResultContainer object
var textExtracted = results.ResultCollection[0].ToString();

使用例:

TextFormattingMode を指定して PDF ドキュメントからテキストコンテンツを抽出する例です。

// Create ExtractTextOptions object to set TextFormattingMode
var options = new ExtractTextOptions(TextFormattingMode.Pure);
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Perform the process
var results = PdfExtractor.ExtractText(options);
// Get the extracted text from the ResultContainer object
var textExtracted = results.ResultCollection[0].ToString();

使用例:

PDF ドキュメントから画像を抽出する例です。

// Create ExtractImagesOptions to set instructions
var options = new ExtractImagesOptions();
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output Directory path
options.AddOutput(new DirectoryDataSource("path_to_results_directory"));
// Perform the process
var results = PdfExtractor.ExtractImages(options);
// Get path to image result
var imageExtracted = results.ResultCollection[0].ToFile();

使用例:

フォームの値を CSV ファイルにエクスポートする例です。

// Create ExtractFormDataToDsvOptions object to set instructions
var options = new ExtractFormDataToDsvOptions(',', true);
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_csv_file.csv"));
// Perform the process
PdfExtractor.ExtractFormData(options);

新しいプラグイン PDF Manager

  • Class PdfManager: プラグインのすべての機能(Merger、Optimizer、Splitter、TableGenerator、TocGenerator)を含みます。
  • Class Merger: まもなく削除されます。
  • Class Optimizer: まもなく削除されます。PdfManager を使用してください。
  • Class Splitter: まもなく削除されます。PdfManager を使用してください。
  • Class TableGenerator: まもなく削除されます。PdfManager を使用してください。
  • Class TocGenerator: まもなく削除されます。PdfManager を使用してください。
  • 詳細は The New Plugin Architecture を参照してください。

使用例:

2 つの PDF ドキュメントをマージする例です。

// Create MergeOptions object to set instructions
var options = new MergeOptions();
// Add input file paths
options.AddInput(new FileDataSource("path_to_your_pdf_file_1.pdf"));
options.AddInput(new FileDataSource("path_to_your_pdf_file_2.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.Merge(options);

使用例:

PDF ドキュメントを分割する例です。

// Create SplitOptions object to set instructions
var options = new SplitOptions();
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file paths
options.AddOutput(new FileDataSource("path_to_result_pdf_file_1.pdf"));
options.AddOutput(new FileDataSource("path_to_result_pdf_file_2.pdf"));
// Perform the process
PdfManager.Split(options);

使用例:

PDF ドキュメントを最適化する例です。

// Create OptimizeOptions object to set instructions
var options = new OptimizeOptions();
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.Optimize(options);

使用例:

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

使用例:

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

使用例:

PDF ドキュメントを圧縮する例です。

// Create CompressOptions object to set instructions
var options = new CompressOptions();
// Add input file path
options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileDataSource("path_to_result_pdf_file.pdf"));
// Perform the process
PdfManager.Compress(options);

使用例:

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

使用例:

PDF ファイルに目次(Table of Contents)を追加する例です。

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

使用例:

ブックマークを生成しながら目次を追加する例です。

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

使用例:

目次をストリームとして保存する例です。

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

TableGenerator の使い勝手向上

  • Class TableGenerator: static であり、コンストラクタの使用は不要です。
  • Class TableGenerator: Obsolete とマークされました。代わりに PdfManager を使用してください。

PdfChatGpt の使い勝手向上

  • Class PdfChatGpt: static であり、コンストラクタの使用は不要です。
  • Class PdfChatGptRequestOptions: CancellationToken プロパティを追加(PdfChatGpt から移動)。

使用例:

メッセージをリクエストに追加して PdfChatGpt プラグインを利用する例です。

var options = new PdfChatGptRequestOptions();
options.AddOutput(new FileDataSource("PdfChatGPT_output.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.
// for cancel
// var cancelTokenSource = new CancellationTokenSource();
// var cToken = cancelTokenSource.Token;
// options.CancellationToken = cToken;

// 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.
await PdfChatGpt.ProcessAsync(options);

修正されたバグ

  • HTML から PDF への変換でメタデータが正しく設定されていなかった問題を修正
  • PDF から PDF/A_3b への変換でテキストフォーマットや画像のスケーリングの問題を修正
  • PDF から PDFA への変換で、生成された PDFA が印刷時にエラーになる問題を修正
  • PDF から HTML への変換で、生成された画像に背景が付く問題を修正
  • HTML から PDF への変換で、一部の中国語文字がボックスとして表示される問題を修正
  • HTML から PDF への変換で、Base64 で埋め込んだカスタムフォントが反映されない問題を修正
  • HTML から PDF への変換で、フォームフィールドの CSS が適用されない問題を修正
  • HTML から PDF への変換で、チャートが正しく描画されない問題を修正
  • HTML から PDFへの変換で、特殊文字が正しくレンダリングされない問題を修正
 日本語