IronPDF How-Tos Set and Edit PDF Metadata How to Set and Edit PDF Metadata ByJordi Bardia July 10, 2023 Updated June 22, 2025 Share: Metadata in a PDF document refers to descriptive information about the document itself. Metadata in a PDF includes information such as the document's title, author, subject, keywords, creation date, modification date, and more. Metadata allows for PDFs to be better indexed and searched in databases. It also increases their searchability on the internet. View the IronPDF YouTube Playlist Get started with IronPDF Start using IronPDF in your project today with a free trial. First Step: Start for Free How to Set and Edit PDF Metadata Download the IronPDF C# library for PDF metadata editing Load an existing PDF or render a new one Access the MetaData property to set and edit the PDF metadata Utilize the metadata dictionary for effective metadata processing Add, edit, or remove custom PDF metadata properties Set and Edit Metadata Example When using IronPDF, setting and editing the generic metadata fields in PDFs is a straightforward process. You can easily access the MetaData property to modify the available metadata fields. :path=/static-assets/pdf/content-code-examples/how-to/metadata-set-edit.cs using IronPdf; using System; // Create a new PDF renderer using ChromePdfRenderer ChromePdfRenderer renderer = new ChromePdfRenderer(); // Render the given HTML as a PDF document PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Metadata</h1>"); // Access the MetaData class to set the pre-defined metadata properties // These metadata properties provide additional information about the PDF document // Set the author of the document pdf.MetaData.Author = "Iron Software"; // Set the creation date of the document to today's date pdf.MetaData.CreationDate = DateTime.Today; // Set the name of the software that created the PDF pdf.MetaData.Creator = "IronPDF"; // Set the keywords for the document, which help in document indexing and searchability pdf.MetaData.Keywords = "ironsoftware,ironpdf,pdf"; // Set the modified date to the current date and time, indicating when the document was last modified pdf.MetaData.ModifiedDate = DateTime.Now; // Set the name of the software that produced the PDF document pdf.MetaData.Producer = "IronPDF"; // Set the subject of the document, providing a brief description of its content pdf.MetaData.Subject = "Metadata Tutorial"; // Set the title of the document pdf.MetaData.Title = "IronPDF Metadata Tutorial"; // Save the PDF document to the specified filename pdf.SaveAs("pdf-with-metadata.pdf"); Imports IronPdf Imports System ' Create a new PDF renderer using ChromePdfRenderer Private renderer As New ChromePdfRenderer() ' Render the given HTML as a PDF document Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Metadata</h1>") ' Access the MetaData class to set the pre-defined metadata properties ' These metadata properties provide additional information about the PDF document ' Set the author of the document pdf.MetaData.Author = "Iron Software" ' Set the creation date of the document to today's date pdf.MetaData.CreationDate = DateTime.Today ' Set the name of the software that created the PDF pdf.MetaData.Creator = "IronPDF" ' Set the keywords for the document, which help in document indexing and searchability pdf.MetaData.Keywords = "ironsoftware,ironpdf,pdf" ' Set the modified date to the current date and time, indicating when the document was last modified pdf.MetaData.ModifiedDate = DateTime.Now ' Set the name of the software that produced the PDF document pdf.MetaData.Producer = "IronPDF" ' Set the subject of the document, providing a brief description of its content pdf.MetaData.Subject = "Metadata Tutorial" ' Set the title of the document pdf.MetaData.Title = "IronPDF Metadata Tutorial" ' Save the PDF document to the specified filename pdf.SaveAs("pdf-with-metadata.pdf") $vbLabelText $csharpLabel Output PDF To view the document metadata, click on the three vertical dots and access the Document properties. Set and Retrieve Metadata Dictionary The GetMetaDataDictionary method allows you to retrieve the existing metadata dictionary and access the 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 the generic metadata fields, it will be considered a custom metadata property. :path=/static-assets/pdf/content-code-examples/how-to/metadata-set-and-get-metadata-dictionary.cs using IronPdf; using System.Collections.Generic; // Initialize a new instance of the ChromePdfRenderer, // which is used to render HTML as a PDF document. ChromePdfRenderer renderer = new ChromePdfRenderer(); // Render HTML content as a PDF document. PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Metadata</h1>"); // Create a dictionary to hold the metadata for the PDF document. Dictionary<string, string> newMetadata = new Dictionary<string, string>(); // Add metadata properties to the dictionary. newMetadata.Add("Title", "How to article"); newMetadata.Add("Author", "IronPDF"); // Set the metadata for the PDF document using the metadata dictionary. pdf.Metadata.SetMetadataDictionary(newMetadata); // Retrieve the metadata dictionary from the PDF document and store it in a new dictionary. Dictionary<string, string> metadataProperties = pdf.Metadata.GetMetadataDictionary(); // The 'metadataProperties' dictionary now contains the metadata // that was initially set for the PDF document. Imports IronPdf Imports System.Collections.Generic ' Initialize a new instance of the ChromePdfRenderer, ' which is used to render HTML as a PDF document. Private renderer As New ChromePdfRenderer() ' Render HTML content as a PDF document. Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Metadata</h1>") ' Create a dictionary to hold the metadata for the PDF document. Private newMetadata As New Dictionary(Of String, String)() ' Add metadata properties to the dictionary. newMetadata.Add("Title", "How to article") newMetadata.Add("Author", "IronPDF") ' Set the metadata for the PDF document using the metadata dictionary. pdf.Metadata.SetMetadataDictionary(newMetadata) ' Retrieve the metadata dictionary from the PDF document and store it in a new dictionary. Dim metadataProperties As Dictionary(Of String, String) = pdf.Metadata.GetMetadataDictionary() ' The 'metadataProperties' dictionary now contains the metadata ' that was initially set for the PDF document. $vbLabelText $csharpLabel Output PDF To view the document metadata, click on the three vertical dots and access the Document properties. Add, Edit, and Remove Custom Metadata Example In addition to the 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 only display the generic metadata and may not retrieve all existing metadata properties. Add and Edit Custom Metadata To add custom metadata, simply 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. :path=/static-assets/pdf/content-code-examples/how-to/metadata-custom-properties.cs // Import necessary namespaces from the IronPdf library using IronPdf; using IronPdf.MetaData; // Create a new instance of ChromePdfRenderer to render HTML into a PDF document ChromePdfRenderer renderer = new ChromePdfRenderer(); // Render an HTML string as a PDF document PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Metadata</h1>"); // Access the custom metadata properties of the PDF document PdfCustomMetadataProperties customProperties = pdf.MetaData.CustomProperties; // Add a custom metadata property with a key-value pair customProperties.Add("foo", "bar"); // Key: "foo", Value: "bar" // Edit the existing custom metadata property customProperties["foo"] = "baz"; // Change the value of the key "foo" to "baz" // The following lines demonstrate how to save the PDF document // Save the PDF document to a file pdf.SaveAs("output.pdf"); ' Import necessary namespaces from the IronPdf library Imports IronPdf Imports IronPdf.MetaData ' Create a new instance of ChromePdfRenderer to render HTML into a PDF document Private renderer As New ChromePdfRenderer() ' Render an HTML string as a PDF document Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Metadata</h1>") ' Access the custom metadata properties of the PDF document Private customProperties As PdfCustomMetadataProperties = pdf.MetaData.CustomProperties ' Add a custom metadata property with a key-value pair customProperties.Add("foo", "bar") ' Key: "foo", Value: "bar" ' Edit the existing custom metadata property customProperties("foo") = "baz" ' Change the value of the key "foo" to "baz" ' The following lines demonstrate how to save the PDF document ' Save the PDF document to a file pdf.SaveAs("output.pdf") $vbLabelText $csharpLabel Remove Custom Metadata There are two ways to remove custom metadata from a PDF document. You can utilize the RemoveMetaDataKey method, accessible through the Metadata property, or use the Remove method from the CustomProperties property. :path=/static-assets/pdf/content-code-examples/how-to/metadata-remove-custom-properties.cs using IronPdf; // Create an instance of ChromePdfRenderer to render HTML into PDF ChromePdfRenderer renderer = new ChromePdfRenderer(); // Render a simple HTML string as a PDF document PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Metadata</h1>"); // Add a custom property to the PDF metadata pdf.MetaData.CustomProperties.Add("willBeDeleted", "value"); // Remove the custom property from the PDF metadata // Remove the metadata key using the built-in method pdf.MetaData.CustomProperties.Remove("willBeDeleted"); // If the first method (Remove) does not suffice, use this to ensure the key is removed. pdf.MetaData.RemoveMetaDataKey("willBeDeleted"); Imports IronPdf ' Create an instance of ChromePdfRenderer to render HTML into PDF Private renderer As New ChromePdfRenderer() ' Render a simple HTML string as a PDF document Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Metadata</h1>") ' Add a custom property to the PDF metadata pdf.MetaData.CustomProperties.Add("willBeDeleted", "value") ' Remove the custom property from the PDF metadata ' Remove the metadata key using the built-in method pdf.MetaData.CustomProperties.Remove("willBeDeleted") ' If the first method (Remove) does not suffice, use this to ensure the key is removed. pdf.MetaData.RemoveMetaDataKey("willBeDeleted") $vbLabelText $csharpLabel Frequently Asked Questions What is PDF metadata? PDF metadata refers to descriptive information about the document, such as the title, author, subject, keywords, creation date, and modification date. It helps make PDFs more searchable and indexable. How do I set and edit PDF metadata? To set and edit PDF metadata using IronPDF, load a PDF document, access the MetaData property, and modify the metadata fields. Then save the PDF document with the updated metadata. Can I add custom metadata to a PDF? Yes, you can add custom metadata to a PDF using IronPDF by accessing the CustomProperties property and utilizing the Add method. How can I remove custom metadata from a PDF document? Custom metadata can be removed from a PDF document using the RemoveMetaDataKey method or the Remove method from the CustomProperties property. What is the purpose of the GetMetaDataDictionary method? The GetMetaDataDictionary method retrieves the existing metadata dictionary of a PDF, allowing access to all metadata information stored within the document. How do I overwrite the metadata dictionary in a PDF? To overwrite the metadata dictionary in a PDF, retrieve it using the GetMetaDataDictionary method, modify it, and then use the SetMetaDataDictionary method to update the PDF with the new dictionary. Is it possible to view custom metadata in standard PDF viewers? Custom metadata is often not visible in standard PDF viewer software, as they typically only display generic metadata. What are generic metadata fields in a PDF? Generic metadata fields in a PDF include standard information like the title, author, subject, and keywords, which are commonly visible in PDF viewer applications. Is any specific library required to handle PDF metadata? Yes, you need to install the IronPDF C# library to set, edit, and manage PDF metadata effectively. What is the function of the SetMetaDataDictionary method? The SetMetaDataDictionary method allows you to rewrite the entire metadata dictionary in a PDF, enabling updates or additions to both standard and custom metadata. Jordi Bardia Chat with engineering team now 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 says it’s one of his favorite aspects of working with Iron Software. Jordi grew up in Miami, Florida and studied Computer Science and Statistics at University of Florida. Ready to Get Started? Start Free Trial Total downloads: 14,143,061 View Licenses >