GroupDocs.Metadata for .NET

Extract Metadata From PDF File In C#

Read & Extract metadata information from a wide range of documents, images, audio & video formats using GroupDocs.Metadata for .NET

Steps for PDF Metadata Extraction in .NET

GroupDocs.Metadata makes it easy for .NET developers to extract to read and extract metadata information from PDF files from within their applications by implementing a few easy steps.

  1. Load the PDF with an instance of .NET class.
  2. Make up a predicate to examine all metadata properties.
  3. Pass the predicate to the FindProperties method.
  4. Iterate through the found properties.
Copy
// Extract PDF metadata properties by various criteria

// Construct Metadata passing PDF path
using (var metadata = new GroupDocs.Metadata.Metadata("input.pdf"))
{
    // extract all metadata properties that fall into a particular category
    var properties = metadata.FindProperties(
      p => p.Tags.Any(t => t.Category == GroupDocs.Metadata.Tagging.Tags.Content));
    // iterate over all properties and display
    foreach (var property in properties)
    {
        Console.WriteLine("{0} = {1}", property.Name, property.Value);
    }

    // extract all properties having a specific type and value
    var year = DateTime.Today.Year;
    properties = metadata.FindProperties(
      p => p.Value.Type == GroupDocs.Metadata.Common.MetadataPropertyType.DateTime && 
      p.Value.ToStruct(DateTime.MinValue).Year == year);

    // display all datetime properties with the year value equal to the current year
    foreach (var property in properties)
    {
        Console.WriteLine("{0} = {1}", property.Name, property.Value);
    }

    // extract all properties having names matching the specified regex
    const string pattern = "^author|company|(.+date.*)$";
    var regex = new System.Text.RegularExpressions.Regex(pattern, 
      System.Text.RegularExpressions.RegexOptions.IgnoreCase);
    properties = metadata.FindProperties(p => regex.IsMatch(p.Name));

    // display properties whose names match the following pattern
    foreach (var property in properties)
    {
        Console.WriteLine("{0} = {1}", property.Name, property.Value);
    }
}
dotnet add package GroupDocs.Metadata
click to copy
copied
More examples Documentation

Search Files Metadata with GroupDocs.Metadata

Securely manage hidden metadata within sensitive documents using .NET applications powered by the GroupDocs.Metadata library.

Search for Metadata in .NET Files

.NET Tools for Comprehensive Metadata Search

Streamline your document processing in .NET with GroupDocs.Metadata. Our software offers powerful tools to search for and manage hidden metadata efficiently.

Precise Metadata Targeting

Target specific metadata with pinpoint accuracy. Configure your search with various filters like text, date, or regular expressions to find exactly the metadata you need.

Effortless Metadata Management

Leverage .NET to process the values of discovered metadata entries. GroupDocs.Metadata empowers you to add, update, or remove metadata effectively within supported file formats.

Read E-Book Metadata in C#

This code example demonstrates how to access metadata properties specific to EPUB e-books

C#


    //  Load the EPUB file into the Metadata object
    using (Metadata metadata = new Metadata("input.epub"))
    {
        //  Retrieve all the built-in metadata
        var root = metadata.GetRootPackage<EpubRootPackage>();

        //  Use the retrieved data for your application's needs
        Console.WriteLine(root.EpubPackage.Version);
        Console.WriteLine(root.EpubPackage.UniqueIdentifier);
        Console.WriteLine(root.EpubPackage.ImageCover != null ? 
            root.EpubPackage.ImageCover.Length : 0);
        Console.WriteLine(root.EpubPackage.Description);
        Console.WriteLine(root.EpubPackage.Title);
    }

AboutGroupDocs.Metadata for .NET API

GroupDocs.Metadata for .NET offers an advanced set of metadata management and manipulation features, allowing developers to easily read, edit, remove, search, compare, replace and export metadata information from images and document formats without using any external software. Extract metadata details from PDF, Word, Excel, PowerPoint, Outlook, OneNote, Visio, Project, AutoCAD, Archive and Multimedia file formats, and perform supported metadata operations with true flexibility.
Learn more
About illustration

Ready to get started?

Download GroupDocs.Metadata for free or get a trial license for full access!

Updating Metadata Properties From Other File Formats

Multi format documents and images metadata editing API for .NET. Retrieve metadata of some of the popular file formats as stated below.

Temporary license tips

1
Sign up with your work email.
Free mail services are not allowed.
2
Use Get a temporary license button on the second step.
 English