How to Set and Edit PDF Metadata in C#

How to Set and Edit PDF Metadata in C# with IronPDF

IronPDF enables developers to programmatically set and edit PDF metadata in C# applications, including standard properties like title, author, and keywords, as well as custom metadata fields for enhanced document organization and searchability. Whether you're building business applications that require document tracking, implementing compliance features, or organizing your PDF library, IronPDF provides comprehensive metadata manipulation capabilities. This functionality integrates seamlessly with IronPDF's HTML to PDF conversion and other document processing features.

Quickstart: Modify PDF Metadata Instantly

Manage PDF metadata using IronPDF with just a few lines of code. Load your PDF, update metadata such as title, author, or keywords, and save your changes. This guide simplifies setting and editing metadata, ensuring your documents are well-organized and searchable. Enhance your PDF capabilities by following this straightforward approach.

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.

    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. Deploy to test on your live environment

    Start using IronPDF in your project today with a free trial
    arrow pointer


How Do I Set and Edit PDF Metadata?

When using IronPDF, setting and editing generic metadata fields in PDFs is straightforward. Access the MetaData property to modify available metadata fields. 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

How Can I View the Metadata in the Output PDF?

To view document metadata, click on the three vertical dots and access Document properties. This metadata is crucial for document organization, especially when implementing PDF/A compliant documents for long-term archival.

How Do I Set and Retrieve the Metadata Dictionary?

The GetMetaDataDictionary method retrieves the existing metadata dictionary and accesses metadata information stored within the document. The SetMetaDataDictionary method provides an effective way to rewrite the metadata dictionary. If a key is not present in generic metadata fields, it becomes a custom metadata property. 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

What Happens When I Use the Metadata Dictionary?

To view document metadata, click on the three vertical dots and access Document properties. The metadata dictionary approach is especially helpful when implementing batch processing workflows or standardizing metadata across multiple documents. For advanced document management scenarios, consider combining this with PDF compression techniques to optimize file storage.

Working with Metadata in Different Contexts

When developing enterprise applications, metadata plays a crucial role in document classification and retrieval. Here's an example of implementing a comprehensive metadata management system:

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

How Do I Add, Edit, and Remove Custom Metadata?

In addition to standard metadata of a PDF document, you can include custom metadata properties. These custom properties are often not visible in PDF viewer software, as they typically display only generic metadata and may not retrieve all existing metadata properties. Custom metadata is particularly valuable when implementing PDF security features or creating specialized document workflows.

How Do I Add and Edit Custom Metadata Properties?

To add custom metadata, access the CustomProperties property and invoke the Add method. Editing custom metadata requires passing the key value to the CustomProperties property and reassigning its value. 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

Advanced Custom Metadata Scenarios

Custom metadata becomes particularly powerful when building document management systems. Here's a comprehensive example demonstrating real-world usage:

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

How Do I Remove Custom Metadata Properties?

Remove custom metadata from a PDF document in two ways. Use the RemoveMetaDataKey method, accessible through the Metadata property, or use the Remove method from the CustomProperties property. 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

Introduction

PDF metadata serves as the backbone of document management systems, enabling efficient organization, searchability, and compliance tracking. IronPDF's metadata capabilities extend beyond simple property setting—they provide a comprehensive framework for building sophisticated document workflows. Whether implementing PDF/UA compliant documents for accessibility or creating custom tracking systems, metadata management is essential.

Best Practices for Metadata Management

  1. Consistency: Establish naming conventions for custom metadata keys
  2. Documentation: Maintain a registry of custom metadata fields used in your system
  3. Validation: Implement validation rules before setting metadata values
  4. Security: Avoid storing sensitive information in metadata unless the PDF is encrypted
  5. Compliance: Ensure metadata meets regulatory requirements for your industry

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.

Ready to see what else you can do? Check out our tutorial page here: Sign and Secure PDFs

Frequently Asked Questions

How do I set PDF metadata properties like title and author in C#?

With IronPDF, you can easily set PDF metadata by accessing the MetaData property of your PDF document. Simply assign a new PdfMetaData object with properties like Title, Author, Subject, Keywords, Creator, and dates. IronPDF makes it straightforward to update these standard metadata fields programmatically.

Can I add custom metadata fields to PDFs beyond the standard properties?

Yes, IronPDF supports custom metadata fields through the metadata dictionary. Using the SetMetaDataDictionary method, you can add any key-value pairs beyond the standard fields. If a key doesn't match generic metadata fields, IronPDF automatically treats it as custom metadata.

How can I retrieve existing metadata from a PDF document?

IronPDF provides the GetMetaDataDictionary method to retrieve all existing metadata from a PDF document. This method returns a dictionary containing both standard and custom metadata fields, allowing you to access and process metadata information stored within the document.

What standard metadata fields are available for editing?

IronPDF supports all standard PDF metadata fields including Title, Author, Subject, Keywords, Creator, Producer, CreationDate, and ModifiedDate. These fields can be set through the PdfMetaData object and are essential for document organization and searchability.

How do I view the metadata after setting it in the PDF?

After using IronPDF to set metadata, you can view it in any PDF reader by accessing the document properties. In most PDF viewers, click on the three vertical dots or go to File menu and select Document Properties to see all metadata fields including those set programmatically.

Can metadata manipulation be combined with other PDF operations?

Absolutely! IronPDF allows you to combine metadata editing with other features like HTML to PDF conversion, PDF forms creation, and digital signatures. This makes it ideal for building comprehensive document management systems or compliance features.

Jordi Bardia
Software Engineer
Jordi is most proficient in Python, C# and C++, when he isn’t leveraging his skills at Iron Software; he’s game programming. Sharing responsibilities for product testing, product development and research, Jordi adds immense value to continual product improvement. The varied experience keeps him challenged and engaged, and he ...
Read More
Ready to Get Started?
Nuget Downloads 17,012,929 | Version: 2025.12 just released