PDFメタデータを設定および編集する方法
PDFドキュメントのメタデータとは、ドキュメント自体についての記述情報を指します。 PDFのメタデータには、文書のタイトル、著者、件名、キーワード、作成日、変更日などの情報が含まれます。 メタデータはPDFがデータベース内でよりよくインデックス付けされ、検索されるために役立ちます。 それにより、インターネット上での検索可能性も向上します。
IronPDFを始めましょう
今日から無料トライアルでIronPDFをあなたのプロジェクトで使い始めましょう。
PDFメタデータを設定および編集する方法
- PDFメタデータ編集用IronPDF C#ライブラリのダウンロード
- 既存のPDFを読み込むか、新しいPDFをレンダリングする
- アクセス メタデータ PDFメタデータを設定・編集するプロパティ
- 効果的なメタデータ処理のためのメタデータ辞書の活用
- カスタムPDFメタデータプロパティの追加、編集、削除
メタデータの設定と編集の例
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
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
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
カスタムメタデータの削除
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