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

IronPDFを使ってC#でPDFメタデータを設定・編集する方法

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

IronPdfは開発者がC#アプリケーションでPDFメタデータをプログラムで設定、編集することを可能にします。これにはタイトル、著者、キーワードのような標準的なプロパティや、ドキュメントの構成と検索性を強化するためのカスタムメタデータフィールドが含まれます。 文書追跡を必要とするビジネスアプリケーションの構築、コンプライアンス機能の実装、PDFライブラリの整理など、IronPDFは包括的なメタデータ操作機能を提供します。 This functionality integrates seamlessly with IronPDF's HTML to PDF conversion and other document processing features.

クイックスタート: PDFメタデータを即座に変更

わずか数行のコードでIronPDFを使ってPDFメタデータを管理します。 PDFを読み込み、タイトル、著者、キーワードなどのメタデータを更新し、変更を保存します。 このガイドは、メタデータの設定と編集を簡単にし、ドキュメントを整理して検索しやすくします。 この簡潔なアプローチに従ってPDFの機能を向上させましょう。

Nuget Icon今すぐ NuGet で PDF を作成してみましょう:

  1. NuGet パッケージ マネージャーを使用して IronPDF をインストールします

    PM > Install-Package IronPdf

  2. このコード スニペットをコピーして実行します。

    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");
  3. 実際の環境でテストするためにデプロイする

    今すぐ無料トライアルでプロジェクトに IronPDF を使い始めましょう
    arrow pointer


PDFメタデータを設定および編集するには?

IronPDFを使用する場合、PDFの一般的なメタデータフィールドの設定や編集は簡単です。 MetaDataプロパティにアクセスして、利用可能なメタデータ・フィールドを変更します。 This functionality is particularly useful when working with PDF forms, digital signatures, or implementing document management systems.

: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");
$vbLabelText   $csharpLabel

出力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();
$vbLabelText   $csharpLabel

メタデータ辞書を使用するとどうなりますか?

ドキュメントのメタデータを表示するには、縦に並んだ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"));
        }
    }
}
$vbLabelText   $csharpLabel

カスタム メタデータを追加、編集、削除するには?

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";
$vbLabelText   $csharpLabel

高度なカスタム メタデータのシナリオ

カスタムメタデータは、文書管理システムを構築する際に特に威力を発揮します。 以下は、実際の使用例を示す包括的な例です:

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}";
        }
    }
}
$vbLabelText   $csharpLabel

カスタム メタデータ プロパティを削除するには?

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");
$vbLabelText   $csharpLabel

はじめに

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フォームの作成、電子署名のような他の機能を組み合わせることができます。そのため、包括的な文書管理システムやコンプライアンス機能の構築に最適です。

Jordi Bardia
ソフトウェアエンジニア
Jordiは、最も得意な言語がPython、C#、C++であり、Iron Softwareでそのスキルを発揮していない時は、ゲームプログラミングをしています。製品テスト、製品開発、研究の責任を分担し、Jordiは継続的な製品改善において多大な価値を追加しています。この多様な経験は彼を挑戦させ続け、興味を持たせており、Iron Softwareで働くことの好きな側面の一つだと言います。Jordiはフロリダ州マイアミで育ち、フロリダ大学でコンピュータサイエンスと統計学を学びました。
準備はできましたか?
Nuget ダウンロード 17,012,929 | バージョン: 2025.12 リリース