PDFメタデータを設定および編集する方法

This article was translated from English: Does it need improvement?
Translated
View the article in English

によって ジョルディ

PDFドキュメントのメタデータとは、ドキュメント自体についての記述情報を指します。 PDFのメタデータには、ドキュメントのタイトル、著者、主題、キーワード、作成日、変更日などの情報が含まれます。 メタデータはPDFがデータベース内でよりよくインデックス付けされ、検索されるために役立ちます。 それにより、インターネット上での検索可能性も向上します。




PDF 用 C# NuGet ライブラリ

でインストール NuGet

Install-Package IronPdf
または
Java PDF JAR(ジャバPDF JAR)

ダウンロード DLL (ディーエルエル)

DLLをダウンロード

プロジェクトに手動でインストールする

PDF 用 C# NuGet ライブラリ

でインストール NuGet

Install-Package IronPdf
または
Java PDF JAR(ジャバPDF JAR)

ダウンロード DLL (ディーエルエル)

DLLをダウンロード

プロジェクトに手動でインストールする

今日からプロジェクトでIronPDFを使い始めましょう。無料のトライアルをお試しください。

最初のステップ:
green arrow pointer

チェックアウト IronPDF オン Nuget 迅速なインストールと展開のために。8百万以上のダウンロード数により、PDFをC#で変革しています。

PDF 用 C# NuGet ライブラリ nuget.org/packages/IronPdf/
Install-Package IronPdf

インストールを検討してください IronPDF DLL 直接。ダウンロードして、プロジェクトまたはGACの形式で手動でインストールしてください。 IronPdf.zip

プロジェクトに手動でインストールする

DLLをダウンロード

メタデータの設定と編集の例

IronPDFを使用すると、PDFの一般的なメタデータフィールドを設定および編集するプロセスは簡単です。 MetaDataプロパティに簡単にアクセスして、利用可能なメタデータフィールドを変更することができます。

:path=/static-assets/pdf/content-code-examples/how-to/metadata-set-edit.cs
using IronPdf;
using System;

ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Metadata</h1>");

// Access the MetaData class and set the pre-defined metadata properties.
pdf.MetaData.Author = "Iron Software";
pdf.MetaData.CreationDate = DateTime.Today;
pdf.MetaData.Creator = "IronPDF";
pdf.MetaData.Keywords = "ironsoftware,ironpdf,pdf";
pdf.MetaData.ModifiedDate = DateTime.Now;
pdf.MetaData.Producer = "IronPDF";
pdf.MetaData.Subject = "Metadata Tutorial";
pdf.MetaData.Title = "IronPDF Metadata Tutorial";

pdf.SaveAs("pdf-with-metadata.pdf");
IRON VB CONVERTER ERROR developers@ironsoftware.com
VB   C#

PDFを出力

ドキュメントのメタデータを表示するには、縦の3つの点をクリックしてドキュメントのプロパティにアクセスしてください。

メタデータ辞書の設定と取得

GetMetaDataDictionaryメソッドを使用すると、既存のメタデータ辞書を取得し、ドキュメント内に保存されているメタデータ情報にアクセスできます。 SetMetaDataDictionaryメソッドは、メタデータ辞書を再作成する効果的な方法を提供します。 汎用メタデータフィールドにキーが存在しない場合、それは顧客メタデータプロパティと見なされます。

:path=/static-assets/pdf/content-code-examples/how-to/metadata-set-and-get-metadata-dictionary.cs
using IronPdf;
using System.Collections.Generic;

ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Metadata</h1>");

Dictionary<string, string> newMetadata = new Dictionary<string, string>();
newMetadata.Add("Title", "How to article");
newMetadata.Add("Author", "IronPDF");

// Set metadata dictionary
pdf.MetaData.SetMetaDataDictionary(newMetadata);

// Retreive metadata dictionary
Dictionary<string, string> metadataProperties = pdf.MetaData.GetMetaDataDictionary();
IRON VB CONVERTER ERROR developers@ironsoftware.com
VB   C#

PDFを出力

ドキュメントのメタデータを表示するには、縦の3つの点をクリックしてドキュメントのプロパティにアクセスしてください。

カスタムメタデータの追加、編集、削除の例

PDFドキュメントの標準メタデータに加えて、カスタムメタデータプロパティを含めることが可能です。 これらのカスタムプロパティは、通常のPDFビューアソフトウェアでは表示されないことが多いです。これは、通常、そのようなソフトウェアが一般的なメタデータのみを表示し、すべての既存のメタデータプロパティを取得するわけではないためです。

カスタムメタデータの追加と編集

カスタムメタデータを追加するには、CustomProperties プロパティにアクセスし、Add メソッドを呼び出します。 カスタムメタデータの編集には、キー値を CustomProperties プロパティに渡して、その値を再割り当てする必要があります。

:path=/static-assets/pdf/content-code-examples/how-to/metadata-custom-properties.cs
using IronPdf;
using IronPdf.MetaData;

ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Metadata</h1>");

PdfCustomMetadataProperties customProperties = pdf.MetaData.CustomProperties;

// Add custom property
customProperties.Add("foo", "bar"); // Key: foo, Value: bar

// Edit custom property
customProperties["foo"] = "baz";
IRON VB CONVERTER ERROR developers@ironsoftware.com
VB   C#

カスタムメタデータの削除

PDFドキュメントからカスタムメタデータを削除する方法は二つあります。 メタデータプロパティを通じてアクセス可能なRemoveMetaDataKeyメソッドを利用するか、CustomPropertiesプロパティのRemoveメソッドを使用することができます。

:path=/static-assets/pdf/content-code-examples/how-to/metadata-remove-custom-properties.cs
using IronPdf;

ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Metadata</h1>");

// Add custom property to be deleted
pdf.MetaData.CustomProperties.Add("willBeDeleted", "value");

// Remove custom property _ two ways
pdf.MetaData.RemoveMetaDataKey("willBeDeleted");
pdf.MetaData.CustomProperties.Remove("willBeDeleted");
IRON VB CONVERTER ERROR developers@ironsoftware.com
VB   C#