IronPDFを使ってC#でPDFメタデータを設定・編集する方法 — PDF編集ガイド
IronPdfは開発者がC#アプリケーションでPDFメタデータをプログラムで設定、編集することを可能にします。これにはタイトル、著者、キーワードのような標準的なプロパティや、ドキュメントの構成と検索性を強化するためのカスタムメタデータフィールドが含まれます。 文書追跡を必要とするビジネスアプリケーションの構築、コンプライアンス機能の実装、PDFライブラリの整理など、IronPDFは包括的なメタデータ操作機能を提供します。 この機能は、IronPDFのHTMLからPDFへの変換やその他のドキュメント処理機能とシームレスに統合されます。
クイックスタート: PDF メタデータを即座に変更する
わずか数行のコードでIronPDFを使ってPDFメタデータを管理します。 PDFを読み込み、タイトル、著者、キーワードなどのメタデータを更新し、変更を保存します。 このガイドは、メタデータの設定と編集を簡単にし、ドキュメントを整理して検索しやすくします。 この簡潔なアプローチに従ってPDFの機能を向上させましょう。
-
IronPDF をNuGetパッケージマネージャでインストール
PM > Install-Package IronPdf -
このコード スニペットをコピーして実行します。
IronPdf.PdfDocument.FromFile("example.pdf") .MetaData = new IronPdf.PdfMetaData { Title="MyDoc", Author="Me", Subject="Demo", Keywords="ironpdf,metadata", Creator="MyApp", Producer="IronPDF", CreationDate=DateTime.Today, ModifiedDate=DateTime.Now } .SaveAs("updated_example.pdf"); -
実際の環境でテストするためにデプロイする
今日プロジェクトで IronPDF を使い始めましょう無料トライアル
最小限のワークフロー(5ステップ)
- PDFメタデータ編集用IronPDF C#ライブラリをダウンロードする。
- 既存のPDFを読み込むか、新しいPDFをレンダリングします
- PDFメタデータを設定・編集するために**MetaData**プロパティにアクセスしてください。
- 効果的なメタデータ処理のためのメタデータ辞書の活用
- カスタムPDFメタデータプロパティの追加、編集、削除
PDFメタデータを設定および編集するには?
IronPDFを使用する場合、PDFの一般的なメタデータフィールドの設定や編集は簡単です。 MetaDataプロパティにアクセスして、利用可能なメタデータ・フィールドを変更します。 この機能は、PDFフォーム、電子署名、またはドキュメント管理システムの実装時に特に役立ちます。
: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");
Imports IronPdf
Imports System
Dim renderer As New ChromePdfRenderer()
Dim pdf As PdfDocument = 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")
出力PDFのメタデータを表示するにはどうすればよいですか?
ドキュメントのメタデータを表示するには、縦に並んだ3つの点をクリックし、ドキュメントのプロパティにアクセスしてください。 This metadata is crucial for document organization, especially when implementing PDF/A compliant documents for long-term archival.
メタデータ辞書を設定および取得するにはどうすればよいですか?
GetMetaDataDictionary メソッドは、既存のメタデータ ディクショナリを取得し、ドキュメント内に保存されているメタデータ情報にアクセスします。 SetMetaDataDictionary メソッドは、メタデータ ディクショナリを書き換える効果的な方法を提供します。 キーが一般的なメタデータフィールドに存在しない場合、それはカスタムメタデータプロパティになります。 This approach is particularly useful when working with merging multiple PDFs and consolidating metadata from different sources.
: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();
Imports IronPdf
Imports System.Collections.Generic
Dim renderer As New ChromePdfRenderer()
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Metadata</h1>")
Dim newMetadata As New Dictionary(Of String, String)()
newMetadata.Add("Title", "How to article")
newMetadata.Add("Author", "IronPDF")
' Set metadata dictionary
pdf.MetaData.SetMetaDataDictionary(newMetadata)
' Retrieve metadata dictionary
Dim metadataProperties As Dictionary(Of String, String) = pdf.MetaData.GetMetaDataDictionary()
メタデータ辞書を使用するとどうなりますか?
ドキュメントのメタデータを表示するには、縦に並んだ3つの点をクリックし、ドキュメントのプロパティにアクセスしてください。 メタデータ辞書のアプローチは、バッチ処理のワークフローを実装したり、複数のドキュメントにわたってメタデータを標準化したりする場合に特に役立ちます。 For advanced document management scenarios, consider combining this with PDF compression techniques to optimize file storage.
さまざまなコンテキストでメタデータを扱う
エンタープライズ・アプリケーションを開発する際、メタデータは文書の分類と検索において重要な役割を果たします。 包括的なメタデータ管理システムの実装例を示します:
using IronPdf;
using System;
using System.Collections.Generic;
public class PDFMetadataManager
{
public static void ProcessBatchMetadata(List<string> pdfPaths)
{
foreach (string path in pdfPaths)
{
var pdf = PdfDocument.FromFile(path);
// Standardize metadata across all documents
pdf.MetaData.Producer = "Company Document System v2.0";
pdf.MetaData.Creator = "IronPDF";
// Add processing timestamp
pdf.MetaData.ModifiedDate = DateTime.Now;
// Add document classification
var metadata = pdf.MetaData.GetMetaDataDictionary();
metadata["DocumentType"] = "Internal Report";
metadata["Department"] = "Finance";
metadata["SecurityLevel"] = "Confidential";
pdf.MetaData.SetMetaDataDictionary(metadata);
pdf.SaveAs(path.Replace(".pdf", "_processed.pdf"));
}
}
}
using IronPdf;
using System;
using System.Collections.Generic;
public class PDFMetadataManager
{
public static void ProcessBatchMetadata(List<string> pdfPaths)
{
foreach (string path in pdfPaths)
{
var pdf = PdfDocument.FromFile(path);
// Standardize metadata across all documents
pdf.MetaData.Producer = "Company Document System v2.0";
pdf.MetaData.Creator = "IronPDF";
// Add processing timestamp
pdf.MetaData.ModifiedDate = DateTime.Now;
// Add document classification
var metadata = pdf.MetaData.GetMetaDataDictionary();
metadata["DocumentType"] = "Internal Report";
metadata["Department"] = "Finance";
metadata["SecurityLevel"] = "Confidential";
pdf.MetaData.SetMetaDataDictionary(metadata);
pdf.SaveAs(path.Replace(".pdf", "_processed.pdf"));
}
}
}
Imports IronPdf
Imports System
Imports System.Collections.Generic
Public Class PDFMetadataManager
Public Shared Sub ProcessBatchMetadata(pdfPaths As List(Of String))
For Each path As String In pdfPaths
Dim pdf = PdfDocument.FromFile(path)
' Standardize metadata across all documents
pdf.MetaData.Producer = "Company Document System v2.0"
pdf.MetaData.Creator = "IronPDF"
' Add processing timestamp
pdf.MetaData.ModifiedDate = DateTime.Now
' Add document classification
Dim metadata = pdf.MetaData.GetMetaDataDictionary()
metadata("DocumentType") = "Internal Report"
metadata("Department") = "Finance"
metadata("SecurityLevel") = "Confidential"
pdf.MetaData.SetMetaDataDictionary(metadata)
pdf.SaveAs(path.Replace(".pdf", "_processed.pdf"))
Next
End Sub
End Class
カスタム メタデータを追加、編集、削除するには?
PDF 文書の標準メタデータに加えて、カスタムメタデータプロパティを含めることができます。 PDF ビ ュ ーア ソ フ ト ウ ェ アは通常、 汎用 メ タ デー タ のみを表示 し 、 既存の メ タ デー タ プ ロ パテ ィ をすべて取得で き ない可能性があ る ためです。 Custom metadata is particularly valuable when implementing PDF security features or creating specialized document workflows.
カスタム メタデータ プロパティを追加および編集するには?
カスタム メタデータを追加するには、 CustomPropertiesプロパティにアクセスし、Add メソッドを呼び出します。 カスタムメタデータを編集するには、キーの値をCustomPropertiesプロパティに渡し、その値を再割り当てする必要があります。 This functionality integrates well with PDF form editing scenarios where you might need to track form submission metadata.
: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";
Imports IronPdf
Imports IronPdf.MetaData
Dim renderer As New ChromePdfRenderer()
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Metadata</h1>")
Dim customProperties As PdfCustomMetadataProperties = pdf.MetaData.CustomProperties
' Add custom property
customProperties.Add("foo", "bar") ' Key: foo, Value: bar
' Edit custom property
customProperties("foo") = "baz"
高度なカスタム メタデータのシナリオ
カスタムメタデータは、文書管理システムを構築する際に特に威力を発揮します。 以下は、実際の使用例を示す包括的な例です:
using IronPdf;
using System;
using System.Linq;
public class DocumentTrackingSystem
{
public static void AddTrackingMetadata(PdfDocument pdf, string userId, string projectId)
{
var customProps = pdf.MetaData.CustomProperties;
// Add tracking information
customProps.Add("ProcessedBy", userId);
customProps.Add("ProcessedDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
customProps.Add("ProjectID", projectId);
customProps.Add("DocumentVersion", "1.0");
customProps.Add("ReviewStatus", "Pending");
// Add workflow metadata
customProps.Add("WorkflowStep", "Initial Review");
customProps.Add("NextReviewer", "John.Doe@company.com");
customProps.Add("DueDate", DateTime.Now.AddDays(7).ToString("yyyy-MM-dd"));
// Add compliance metadata
customProps.Add("ComplianceChecked", "false");
customProps.Add("RetentionPeriod", "7 years");
customProps.Add("Classification", "Internal Use Only");
}
public static void UpdateReviewStatus(PdfDocument pdf, string status, string reviewer)
{
var customProps = pdf.MetaData.CustomProperties;
// Update existing properties
customProps["ReviewStatus"] = status;
customProps["LastReviewedBy"] = reviewer;
customProps["LastReviewDate"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
// Increment version if approved
if (status == "Approved" && customProps.ContainsKey("DocumentVersion"))
{
var currentVersion = customProps["DocumentVersion"];
var versionParts = currentVersion.Split('.');
var minorVersion = int.Parse(versionParts[1]) + 1;
customProps["DocumentVersion"] = $"{versionParts[0]}.{minorVersion}";
}
}
}
using IronPdf;
using System;
using System.Linq;
public class DocumentTrackingSystem
{
public static void AddTrackingMetadata(PdfDocument pdf, string userId, string projectId)
{
var customProps = pdf.MetaData.CustomProperties;
// Add tracking information
customProps.Add("ProcessedBy", userId);
customProps.Add("ProcessedDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
customProps.Add("ProjectID", projectId);
customProps.Add("DocumentVersion", "1.0");
customProps.Add("ReviewStatus", "Pending");
// Add workflow metadata
customProps.Add("WorkflowStep", "Initial Review");
customProps.Add("NextReviewer", "John.Doe@company.com");
customProps.Add("DueDate", DateTime.Now.AddDays(7).ToString("yyyy-MM-dd"));
// Add compliance metadata
customProps.Add("ComplianceChecked", "false");
customProps.Add("RetentionPeriod", "7 years");
customProps.Add("Classification", "Internal Use Only");
}
public static void UpdateReviewStatus(PdfDocument pdf, string status, string reviewer)
{
var customProps = pdf.MetaData.CustomProperties;
// Update existing properties
customProps["ReviewStatus"] = status;
customProps["LastReviewedBy"] = reviewer;
customProps["LastReviewDate"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
// Increment version if approved
if (status == "Approved" && customProps.ContainsKey("DocumentVersion"))
{
var currentVersion = customProps["DocumentVersion"];
var versionParts = currentVersion.Split('.');
var minorVersion = int.Parse(versionParts[1]) + 1;
customProps["DocumentVersion"] = $"{versionParts[0]}.{minorVersion}";
}
}
}
Imports IronPdf
Imports System
Imports System.Linq
Public Class DocumentTrackingSystem
Public Shared Sub AddTrackingMetadata(pdf As PdfDocument, userId As String, projectId As String)
Dim customProps = pdf.MetaData.CustomProperties
' Add tracking information
customProps.Add("ProcessedBy", userId)
customProps.Add("ProcessedDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
customProps.Add("ProjectID", projectId)
customProps.Add("DocumentVersion", "1.0")
customProps.Add("ReviewStatus", "Pending")
' Add workflow metadata
customProps.Add("WorkflowStep", "Initial Review")
customProps.Add("NextReviewer", "John.Doe@company.com")
customProps.Add("DueDate", DateTime.Now.AddDays(7).ToString("yyyy-MM-dd"))
' Add compliance metadata
customProps.Add("ComplianceChecked", "false")
customProps.Add("RetentionPeriod", "7 years")
customProps.Add("Classification", "Internal Use Only")
End Sub
Public Shared Sub UpdateReviewStatus(pdf As PdfDocument, status As String, reviewer As String)
Dim customProps = pdf.MetaData.CustomProperties
' Update existing properties
customProps("ReviewStatus") = status
customProps("LastReviewedBy") = reviewer
customProps("LastReviewDate") = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
' Increment version if approved
If status = "Approved" AndAlso customProps.ContainsKey("DocumentVersion") Then
Dim currentVersion = customProps("DocumentVersion")
Dim versionParts = currentVersion.Split("."c)
Dim minorVersion = Integer.Parse(versionParts(1)) + 1
customProps("DocumentVersion") = $"{versionParts(0)}.{minorVersion}"
End If
End Sub
End Class
カスタム メタデータ プロパティを削除するには?
2つの方法でPDF文書からカスタムメタデータを削除します。 Metadata プロパティからアクセスできる RemoveMetaDataKey メソッドを使用するか、 CustomPropertiesプロパティから Remove メソッドを使用します。 This is particularly useful when sanitizing PDFs for public distribution or preparing documents for archival.
: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");
Imports IronPdf
Dim renderer As New ChromePdfRenderer()
Dim pdf As PdfDocument = 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")
はじめに
PDFメタデータは、文書管理システムのバックボーンとして機能し、効率的な整理、検索、コンプライアンス追跡を可能にします。 IronPdfのメタデータ機能は単純なプロパティ設定にとどまらず、洗練されたドキュメントワークフローを構築するための包括的なフレームワークを提供します。 Whether implementing PDF/UA compliant documents for accessibility or creating custom tracking systems, metadata management is essential.
メタデータ管理のベストプラクティス
1.一貫性: カスタムメタデータキーの命名規則を確立する。 2.ドキュメント:システムで使用されるカスタムメタデータフィールドのレジストリを維持する。 3.バリデーション: メタデータの値を設定する前にバリデーションルールを実装する。 4.セキュリティ:PDFが暗号化されていない限り、機密情報をメタデータに保存することは避けてください。 5.コンプライアンス: メタデータが業界の規制要件を満たしていることを確認します。
By leveraging IronPDF's metadata capabilities alongside features like digital signatures and PDF encryption, you can build robust document management solutions that meet enterprise requirements.
次に何ができるのかを見てみましょうか? こちらのチュートリアルページをご覧ください: PDFの署名とセキュリティの確保
よくある質問
C# で PDF の メ タ デー タ プ ロ パテ ィ ( タ イ ト ルや著者な ど) を設定す る 方法は?
IronPDFを使えば、PDFドキュメントのMetaDataプロパティにアクセスすることで簡単にPDFメタデータを設定することができます。タイトル、著者、件名、キーワード、作成者、日付のようなプロパティを持つ新しいPdfMetaDataオブジェクトを割り当てるだけです。IronPDFはこれらの標準的なメタデータフィールドをプログラムで簡単に更新することができます。
PDFに標準プロパティ以外のカスタムメタデータフィールドを追加できますか?
はい、IronPDFはメタデータ辞書を通してカスタムのメタデータフィールドをサポートします。SetMetaDataDictionaryメソッドを使うことで、標準的なフィールド以外にも任意のキーと値のペアを追加することができます。キーが一般的なメタデータフィールドにマッチしない場合、IronPDFは自動的にそれをカスタムメタデータとして扱います。
PDF文書から既存のメタデータを取得する方法を教えてください。
IronPDFはGetMetaDataDictionaryメソッドを提供し、PDFドキュメントからすべての既存のメタデータを取得します。このメソッドは標準とカスタムの両方のメタデータフィールドを含む辞書を返すので、ドキュメント内に保存されているメタデータ情報にアクセスして処理することができます。
編集可能な標準メタデータフィールドは?
IronPDFはタイトル、著者、件名、キーワード、作成者、制作者、CreationDate、ModifiedDateを含むすべての標準PDFメタデータフィールドをサポートしています。これらのフィールドはPdfMetaDataオブジェクトを通して設定することができ、ドキュメントの整理や検索に不可欠です。
PDFにメタデータを設定した後、どのようにメタデータを表示しますか?
IronPDFを使用してメタデータを設定した後、ドキュメントのプロパティにアクセスすることで、どのPDFリーダーでも表示することができます。ほとんどのPDFビューアでは、3つの縦の点をクリックするか、ファイルメニューからドキュメントプロパティを選択すると、プログラムで設定されたものを含むすべてのメタデータフィールドが表示されます。
メタデータ操作を他のPDF操作と組み合わせることはできますか?
もちろんです!IronPDFはメタデータの編集とHTMLからPDFへの変換、PDFフォームの作成、電子署名のような他の機能を組み合わせることができます。そのため、包括的な文書管理システムやコンプライアンス機能の構築に最適です。

