Cómo establecer y editar metadatos de PDF en C#

How to Set and Edit PDF Metadata

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

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.

Quickstart: Modify PDF Metadata Instantly

Easily manage your PDF metadata using IronPDF with just a few lines of code. Load your PDF, update the metadata such as title, author, or keywords, and save your changes effortlessly. 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


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;

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
$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;

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
$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
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
$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;

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

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

Preguntas Frecuentes

¿Qué son los metadatos PDF y por qué son importantes?

Los metadatos PDF consisten en información como el título del documento, autor, asunto, palabras clave y fechas de creación y modificación. Estos metadatos mejoran la capacidad de búsqueda e indexación de los PDF en bases de datos y en internet, facilitando su localización y gestión.

¿Cómo configurar metadatos PDF con C#?

Puedes configurar los metadatos de un PDF usando IronPDF al descargar primero la biblioteca, cargar un PDF existente y acceder a la propiedad MetaData para modificar los campos de metadatos como título, autor y palabras clave.

¿Cómo puedo recuperar y modificar el diccionario de metadatos en un PDF?

Para recuperar y modificar el diccionario de metadatos en un PDF, usa el método GetMetaDataDictionary de IronPDF para acceder a los metadatos actuales. Modifica el diccionario según sea necesario y luego aplica los cambios utilizando el método SetMetaDataDictionary.

¿Puede añadirse metadatos personalizados a un documento PDF?

Sí, los metadatos personalizados pueden añadirse a un PDF usando IronPDF al acceder a la propiedad CustomProperties y usar el método Add para insertar pares clave-valor personalizados.

¿Cómo elimino metadatos personalizados específicos de un PDF?

Para eliminar metadatos personalizados específicos de un PDF, utiliza el método RemoveMetaDataKey a través de la propiedad MetaData o aplica el método Remove en la propiedad CustomProperties en IronPDF.

¿Cuáles son los pasos para editar metadatos PDF con IronPDF?

Para editar metadatos PDF con IronPDF, descarga la biblioteca, carga tu PDF, accede a la propiedad MetaData para cambiar los campos de metadatos y luego guarda el documento con los metadatos actualizados.

¿Es posible ver metadatos personalizados en la mayoría de los visores de PDF?

Los metadatos personalizados generalmente no son visibles en la mayoría de los visores de PDF, ya que normalmente muestran solo campos de metadatos estándar como título y autor.

¿Cómo empiezo a usar IronPDF para la edición de metadatos en PDFs?

Para comenzar a usar IronPDF para la edición de metadatos, descarga la biblioteca desde NuGet, carga tu documento PDF en C#, y utiliza los métodos proporcionados para acceder y modificar las propiedades de metadatos.

¿Qué método permite la adición de propiedades de metadatos personalizados en IronPDF?

En IronPDF, las propiedades de metadatos personalizados pueden añadirse usando la propiedad CustomProperties, donde puedes usar el método Add para insertar metadatos personalizados.

¿Existen limitaciones para ver metadatos en los visores de PDF?

Sí, los visores de PDF estándar suelen mostrar solo campos genéricos de metadatos, y los metadatos personalizados podrían no ser visibles sin herramientas especializadas como IronPDF.

¿IronPDF es totalmente compatible con .NET 10 cuando se trabaja con metadatos?

Sí, IronPDF ofrece compatibilidad total con .NET 10 (su lanzamiento está previsto para noviembre de 2025). Esto significa que todas las funciones de metadatos (configuración de campos estándar, gestión de propiedades de metadatos personalizadas, lectura/modificación de diccionarios de metadatos) funcionan de inmediato, sin necesidad de soluciones alternativas. ([ironpdf.com](https://ironpdf.com/blog/using-ironpdf/net-pdf-generation/?utm_source=openai))

Jordi Bardia
Ingeniero de Software
Jordi es más competente en Python, C# y C++. Cuando no está aprovechando sus habilidades en Iron Software, está programando juegos. Compartiendo responsabilidades para pruebas de productos, desarrollo de productos e investigación, Jordi agrega un valor inmenso a la mejora continua del producto. La experiencia variada lo mantiene ...
Leer más
¿Listo para empezar?
Nuget Descargas 16,154,058 | Versión: 2025.11 recién lanzado