How to use OpenAI for PDF

This article was translated from English: Does it need improvement?
Translated
View the article in English
class="container-fluid">
class="row">
class="col-md-2"> Chatgpt related to How to use OpenAI for PDF

OpenAIは、営利法人のOpenAI LPとその非営利親会社であるOpenAI Inc.からなる人工知能の研究機関です。人類全体に利益をもたらす形でデジタルインテリジェンスを進化させることを目的として設立されました。 OpenAIは、人工知能(AI)のさまざまな分野で研究を行い、安全で有益、かつアクセス可能なAI技術の開発を目指しています。

IronPdf.Extensions.AI NuGetパッケージは、PDFの改良のためにOpenAIを有効にします:要約、クエリ、および記憶化。 このパッケージは、Microsoft Semantic Kernelを利用します。

クイックスタート:IronPDFとOpenAIでPDFを要約する

C#でIronPDFを使用して、PDF処理ワークフローにOpenAIを統合する方法を学びましょう。 この簡単な例では、PDFドキュメントの要約を迅速に生成する方法を示します。 数行のコードで、AIを活用してPDFの機能を簡単に向上させることができます。

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronPDF with NuGet Package Manager

    PM > Install-Package IronPdf

  2. Copy and run this code snippet.

    // Install-Package IronPdf.Extensions.AI
    await IronPdf.AI.PdfAIEngine.Summarize("input.pdf", "summary.txt", azureEndpoint, azureApiKey);
  3. Deploy to test on your live environment

    Start using IronPDF in your project today with a free trial
    arrow pointer
class="hsg-featured-snippet">

最小ワークフロー(5つのステップ)

  1. OpenAIをPDFで利用するためのC#ライブラリをダウンロード
  2. OpenAIのAzureエンドポイントとAPIキーを準備する
  3. ターゲットのPDFドキュメントをインポートする
  4. Summarizeメソッドを使用してPDFの要約を生成する
  5. Queryメソッドを使用して連続クエリを行う


IronPdfパッケージに加えて、以下の2つのパッケージも必要です:

PDF要約の例

OpenAI機能を使用するには、AzureエンドポイントとAPIキーが必要です。 以下のコード例に従ってSemantic Kernelを設定してください。 PDFドキュメントをインポートし、Summarizeメソッドを使用してPDFドキュメントの要約を生成します。 OpenAIを利用したPDF要約の例からサンプルPDFファイルをダウンロードできます。

ご注意 注:Semantic Kernelのメソッドは実験的であるため、SKEXP0001、SKEXP0010、SKEXP0050エラーが発生する可能性があります。 これらのエラーを抑制するために、以下のコードを.csprojファイルに追加してください:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <NoWarn>$(NoWarn);SKEXP0001,SKEXP0010,SKEXP0050</NoWarn>
  </PropertyGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <NoWarn>$(NoWarn);SKEXP0001,SKEXP0010,SKEXP0050</NoWarn>
  </PropertyGroup>
</Project>
XML

C#でSemantic Kernelを使用してPDFを要約する方法の例を示します:

:path=/static-assets/pdf/content-code-examples/how-to/openai-summarize.cs
using IronPdf;
using IronPdf.AI;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.Memory;
using System;
using System.Threading.Tasks;

// Setup OpenAI
var azureEndpoint = "<<enter your azure endpoint here>>";
var apiKey = "<<enter your azure API key here>>";
var builder = Kernel.CreateBuilder()
    .AddAzureOpenAITextEmbeddingGeneration("oaiembed", azureEndpoint, apiKey)
    .AddAzureOpenAIChatCompletion("oaichat", azureEndpoint, apiKey);
var kernel = builder.Build();

// Setup Memory
var memory_builder = new MemoryBuilder()
    // optionally use new ChromaMemoryStore("http://127.0.0.1:8000") (see https://github.com/microsoft/semantic-kernel/blob/main/dotnet/notebooks/09-memory-with-chroma.ipynb)
    .WithMemoryStore(new VolatileMemoryStore())
    .WithAzureOpenAITextEmbeddingGeneration("oaiembed", azureEndpoint, apiKey);
var memory = memory_builder.Build();

// Initialize IronAI
IronDocumentAI.Initialize(kernel, memory);

License.LicenseKey = "<<enter your IronPdf license key here";

// Import PDF document
PdfDocument pdf = PdfDocument.FromFile("wikipedia.pdf");

// Summarize the document
Console.WriteLine("Please wait while I summarize the document...");
string summary = await pdf.Summarize(); // optionally pass AI instance or use AI instance directly
Console.WriteLine($"Document summary: {summary}\n\n");
Imports Microsoft.VisualBasic
Imports IronPdf
Imports IronPdf.AI
Imports Microsoft.SemanticKernel
Imports Microsoft.SemanticKernel.Connectors.OpenAI
Imports Microsoft.SemanticKernel.Memory
Imports System
Imports System.Threading.Tasks

' Setup OpenAI
Private azureEndpoint = "<<enter your azure endpoint here>>"
Private apiKey = "<<enter your azure API key here>>"
Private builder = Kernel.CreateBuilder().AddAzureOpenAITextEmbeddingGeneration("oaiembed", azureEndpoint, apiKey).AddAzureOpenAIChatCompletion("oaichat", azureEndpoint, apiKey)
Private kernel = builder.Build()

' Setup Memory
Private memory_builder = (New MemoryBuilder()).WithMemoryStore(New VolatileMemoryStore()).WithAzureOpenAITextEmbeddingGeneration("oaiembed", azureEndpoint, apiKey)
Private memory = memory_builder.Build()

' Initialize IronAI
IronDocumentAI.Initialize(kernel, memory)

License.LicenseKey = "<<enter your IronPdf license key here"

' Import PDF document
Dim pdf As PdfDocument = PdfDocument.FromFile("wikipedia.pdf")

' Summarize the document
Console.WriteLine("Please wait while I summarize the document...")
Dim summary As String = Await pdf.Summarize() ' optionally pass AI instance or use AI instance directly
Console.WriteLine($"Document summary: {summary}" & vbLf & vbLf)
$vbLabelText   $csharpLabel

出力の要約

class="content-img-align-center">
class="center-image-wrapper"> PDFドキュメントの要約

連続クエリの例

単一のクエリがすべてのシナリオに適しているとは限りません。 IronPdf.Extensions.AIパッケージには、ユーザーが連続クエリを実行できるQueryメソッドも提供されています。

:path=/static-assets/pdf/content-code-examples/how-to/openai-query.cs
using IronPdf;
using IronPdf.AI;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.Memory;
using System;
using System.Threading.Tasks;

// Setup OpenAI
var azureEndpoint = "<<enter your azure endpoint here>>";
var apiKey = "<<enter your azure API key here>>";
var builder = Kernel.CreateBuilder()
    .AddAzureOpenAITextEmbeddingGeneration("oaiembed", azureEndpoint, apiKey)
    .AddAzureOpenAIChatCompletion("oaichat", azureEndpoint, apiKey);
var kernel = builder.Build();

// Setup Memory
var memory_builder = new MemoryBuilder()
    // optionally use new ChromaMemoryStore("http://127.0.0.1:8000") (see https://github.com/microsoft/semantic-kernel/blob/main/dotnet/notebooks/09-memory-with-chroma.ipynb)
    .WithMemoryStore(new VolatileMemoryStore())
    .WithAzureOpenAITextEmbeddingGeneration("oaiembed", azureEndpoint, apiKey);
var memory = memory_builder.Build();

// Initialize IronAI
IronDocumentAI.Initialize(kernel, memory);

License.LicenseKey = "<<enter your IronPdf license key here";

// Import PDF document
PdfDocument pdf = PdfDocument.FromFile("wikipedia.pdf");

// Continuous query
while (true)
{
    Console.Write("User Input: ");
    var response = await pdf.Query(Console.ReadLine());
    Console.WriteLine($"\n{response}");
}
Imports Microsoft.VisualBasic
Imports IronPdf
Imports IronPdf.AI
Imports Microsoft.SemanticKernel
Imports Microsoft.SemanticKernel.Connectors.OpenAI
Imports Microsoft.SemanticKernel.Memory
Imports System
Imports System.Threading.Tasks

' Setup OpenAI
Private azureEndpoint = "<<enter your azure endpoint here>>"
Private apiKey = "<<enter your azure API key here>>"
Private builder = Kernel.CreateBuilder().AddAzureOpenAITextEmbeddingGeneration("oaiembed", azureEndpoint, apiKey).AddAzureOpenAIChatCompletion("oaichat", azureEndpoint, apiKey)
Private kernel = builder.Build()

' Setup Memory
Private memory_builder = (New MemoryBuilder()).WithMemoryStore(New VolatileMemoryStore()).WithAzureOpenAITextEmbeddingGeneration("oaiembed", azureEndpoint, apiKey)
Private memory = memory_builder.Build()

' Initialize IronAI
IronDocumentAI.Initialize(kernel, memory)

License.LicenseKey = "<<enter your IronPdf license key here"

' Import PDF document
Dim pdf As PdfDocument = PdfDocument.FromFile("wikipedia.pdf")

' Continuous query
Do
	Console.Write("User Input: ")
	Dim response = Await pdf.Query(Console.ReadLine())
	Console.WriteLine($vbLf & "{response}")
Loop
$vbLabelText   $csharpLabel

よくある質問

OpenAI を使用して C# で PDF をどのように強化できますか?

C# で PDF ドキュメントを強化するには、要約やクエリなどの機能を可能にする `IronPdf.Extensions.AI` NuGet パッケージを使用します。これは Azure エンドポイントと OpenAI 統合用の API キーを使用することを伴います。

C# での PDF 処理に OpenAI を統合するために必要なものは何ですか?

C# での PDF 処理に OpenAI を統合するには、`IronPdf` と `IronPdf.Extensions.AI` パッケージ、Microsoft Semantic Kernel、Azure エンドポイント、および API キーが必要です。

C# における OpenAI を使った PDF ドキュメントの要約はどうやって行いますか?

PDF ドキュメントを要約するには、`IronPdf.Extensions.AI` パッケージの `Summarize` メソッドを使用します。あなたの PDF ドキュメントをインポートし、このメソッドを Azure エンドポイントと API キーを提供することで適用します。

C# で AI を使用して PDF に対する継続的なクエリを行うことはできますか?

はい、`IronPdf.Extensions.AI` パッケージの `Query` メソッドを使用することで、PDF ドキュメントから動的な情報抽出を可能にする継続的なクエリを実行できます。

C# プロジェクトで実験的なエラーワーニングを抑止する方法は何ですか?

SKEXP0001、SKEXP0010、SKEXP0050 などの実験的エラーワーニングを抑制するには、次のコードを .csproj ファイルに追加します: <NoWarn>$(NoWarn);SKEXP0001,SKEXP0010,SKEXP0050</NoWarn>

PDF の強化において Microsoft Semantic Kernel はどのような役割を果たしますか?

Microsoft Semantic Kernel は、PDF ドキュメントに対する `Summarize` や `Query` といったメソッドを設定・実行するために使用され、`IronPdf.Extensions.AI` パッケージを介して OpenAI の機能を可能にします。

PDF 要約において OpenAI を使用する利点は何ですか?

OpenAI を使用することで、大規模ドキュメントの要約を簡潔に提供し、重要な情報を素早く抽出することが可能です。これは `IronPdf.Extensions.AI` パッケージの `Summarize` メソッドを使用して実現されます。

OpenAI 拡張機能を使用する場合、IronPDF は .NET 10 と互換性がありますか?

はい。IronPDFは.NET 10と完全に互換性があり、`IronPdf.Extensions.AI`パッケージは特別な設定なしで.NET 10プロジェクトで動作します。このライブラリは、.NET 10で導入された最新のランタイムの改善と言語機能をサポートしています。

Curtis Chau
テクニカルライター

Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。

開発以外にも、CurtisはIoT(Internet of Things)への強い関心を持ち、ハードウェアとソフトウェアの統合方法を模索しています。余暇には、ゲームをしたりDiscordボットを作成したりして、技術に対する愛情と創造性を組み合わせています。

準備はいいですか?
Nuget ダウンロード 16,154,058 | バージョン: 2025.11 ただ今リリースされました