Skip to content

Extract Document Metadata

Every Office format embeds a small set of “core properties” — author, last-modified date, title, subject, keywords — plus a per-format extended set. Office Oxide surfaces both.

Format & basic info

The Document handle exposes the format name and counts (sheets, slides, sections):

Python

from office_oxide import Document

with Document.open("report.docx") as doc:
    print(doc.format)            # "docx"
    print(doc.detect_format())   # confirms via magic bytes

Rust

use office_oxide::{Document, DocumentFormat};

let doc = Document::open("report.docx")?;
assert_eq!(doc.format(), DocumentFormat::Docx);

JavaScript

using doc = Document.open('report.docx');
console.log(doc.format);        // "docx"

Go

doc, err := officeoxide.Open("report.docx")
if err != nil { log.Fatal(err) }
defer doc.Close()

fmtName, _ := doc.Format()   // "docx"
fmt.Println(fmtName)

C#

using OfficeOxide;

using var doc = Document.Open("report.docx");
Console.WriteLine(doc.Format);   // "docx"

Core properties

For OOXML formats, core properties live in docProps/core.xml. Drop into the format-specific accessor:

Python

from office_oxide import Document

with Document.open("report.docx") as doc:
    docx = doc.as_docx()
    props = docx.core_properties()
    print(props.title)            # str | None
    print(props.author)           # str | None
    print(props.created)          # datetime | None
    print(props.modified)         # datetime | None
    print(props.subject)          # str | None
    print(props.keywords)         # str | None

Rust

use office_oxide::Document;

let doc = Document::open("report.docx")?;
if let Some(docx) = doc.as_docx() {
    let props = docx.core_properties();
    println!("{:?}", props.title);
    println!("{:?}", props.author);
}

The same core_properties() accessor exists on as_xlsx() and as_pptx().

Go

Go exposes core properties via the unified JSON IR:

doc, _ := officeoxide.Open("report.docx")
defer doc.Close()

irJSON, _ := doc.ToIRJSON()
var ir struct {
    Metadata struct {
        Title    string `json:"title"`
        Author   string `json:"author"`
        Created  string `json:"created"`
        Modified string `json:"modified"`
        Subject  string `json:"subject"`
        Keywords string `json:"keywords"`
    } `json:"metadata"`
}
json.Unmarshal([]byte(irJSON), &ir)
fmt.Println(ir.Metadata.Title, ir.Metadata.Author)

C#

using OfficeOxide;
using System.Text.Json;

using var doc = Document.Open("report.docx");
using var ir = JsonDocument.Parse(doc.ToIrJson());

var meta = ir.RootElement.GetProperty("metadata");
Console.WriteLine(meta.GetProperty("title").GetString());
Console.WriteLine(meta.GetProperty("author").GetString());
Console.WriteLine(meta.GetProperty("created").GetString());

Extended (app) properties

docProps/app.xml holds extended metadata: page count, word count, paragraphs, slide count, application name and version, hyperlinks, etc.

Python

with Document.open("report.docx") as doc:
    app = doc.as_docx().app_properties()
    print(app.application)   # "Microsoft Office Word"
    print(app.app_version)
    print(app.pages)
    print(app.words)
    print(app.paragraphs)

For PPTX, app_properties() exposes slides, notes, presentation_format, etc. For XLSX, it exposes the sheet name list.

Custom properties

Both core_properties() and app_properties() cover the standard sets. For application-defined custom keys (set via Word’s “Document Properties → Advanced Properties”), use:

with Document.open("report.docx") as doc:
    custom = doc.as_docx().custom_properties()
    for name, value in custom.items():
        print(name, value)

Legacy formats

DOC, XLS, and PPT store metadata in the OLE2 \005SummaryInformation and \005DocumentSummaryInformation streams. Office Oxide parses these into the same core_properties() shape:

with Document.open("legacy.doc") as doc:
    props = doc.as_doc().core_properties()
    print(props.author, props.created)

Why this matters

  • Search indexing — title, author, and keywords power document discovery.
  • Compliance — last-modified, creator, and revision history feed audit trails.
  • De-duplication — author + title + created date is a cheap-but-effective fingerprint.
  • Stripping PII — read core properties before publishing, then use EditableDocument to clear them.

See also