GemBox.Document is a .NET component that enables you to read, write, edit, convert, and print document files from your .NET applications using one simple API.

Word File Properties

Document can contain built-in and custom properties.

Following example shows how to read built-in and custom document properties.

Screenshot
Document Properties Screenshot

See the full code below, use Run Example to execute.

Upload your file(Drag files here)

Download a sample file

using System;
using System.IO;
using System.Linq;
using GemBox.Document;
using GemBox.Document.Drawing;

class Sample
{
    [STAThread]
    static void Main(string[] args)
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        DocumentModel document = DocumentModel.Load("Reading.docx");

        Paragraph builtInPara = new Paragraph(document,
            new Run(document, "Built-in document properties:"),
            new SpecialCharacter(document, SpecialCharacterType.LineBreak));
        builtInPara.ParagraphFormat.Alignment = HorizontalAlignment.Left;

        foreach (var docProp in document.DocumentProperties.BuiltIn)
        {
            builtInPara.Inlines.Add(
                new Run(document, string.Format("{0}: {1}", docProp.Key, docProp.Value)));

            builtInPara.Inlines.Add(new SpecialCharacter(document, SpecialCharacterType.LineBreak));
        }

        Paragraph customPropPara = new Paragraph(document,
            new Run(document, "Custom document properties:"),
            new SpecialCharacter(document, SpecialCharacterType.LineBreak));
        customPropPara.ParagraphFormat.Alignment = HorizontalAlignment.Left;

        foreach (var docProp in document.DocumentProperties.Custom)
        {
            customPropPara.Inlines.Add(
                new Run(document, string.Format("{0}: {1} (Type: {2})", docProp.Key, docProp.Value, docProp.Value.GetType())));

            customPropPara.Inlines.Add(new SpecialCharacter(document, SpecialCharacterType.LineBreak));
        }

        document.Sections.Clear();
        document.Sections.Add(new Section(document, builtInPara, customPropPara));

        document.Save("Document Properties.docx");
    }
}
Imports System
Imports System.IO
Imports System.Linq
Imports GemBox.Document
Imports GemBox.Document.Drawing

Module Samples

    Sub Main()

        ' If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        Dim document As DocumentModel = DocumentModel.Load("Reading.docx")

        Dim builtInPara As New Paragraph(document,
                                New Run(document, "Built-in document properties:"),
                                New SpecialCharacter(document, SpecialCharacterType.LineBreak))
        builtInPara.ParagraphFormat.Alignment = HorizontalAlignment.Left

        For Each docProp In document.DocumentProperties.BuiltIn

            builtInPara.Inlines.Add(
                New Run(document, String.Format("{0}: {1}", docProp.Key, docProp.Value)))

            builtInPara.Inlines.Add(
                New SpecialCharacter(document, SpecialCharacterType.LineBreak))

        Next

        Dim customPropPara As New Paragraph(document,
                                New Run(document, "Custom document properties:"),
                                New SpecialCharacter(document, SpecialCharacterType.LineBreak))
        customPropPara.ParagraphFormat.Alignment = HorizontalAlignment.Left

        For Each docProp In document.DocumentProperties.Custom

            customPropPara.Inlines.Add(
                New Run(document, String.Format("{0}: {1} (Type: {2})", docProp.Key, docProp.Value, docProp.Value.GetType())))

            customPropPara.Inlines.Add(
                New SpecialCharacter(document, SpecialCharacterType.LineBreak))

        Next

        document.Sections.Clear()
        document.Sections.Add(New Section(document, builtInPara, customPropPara))

        document.Save("Document Properties.docx")

    End Sub

End Module

Check next sample.