// Copyright 2017 FoxyUtils ehf. All rights reserved. package main import ( "fmt" "log" "os" "time" "github.com/unidoc/unioffice/v2/common/license" "github.com/unidoc/unioffice/v2/document" ) func init() { // Make sure to load your metered License API key prior to using the library. // If you need a key, you can sign up and create a free one at https://cloud.unidoc.io err := license.SetMeteredKey(os.Getenv(`UNIDOC_LICENSE_API_KEY`)) if err != nil { panic(err) } } func main() { doc, err := document.Open("document.docx") if err != nil { log.Fatalf("error opening document: %s", err) } defer doc.Close() cp := doc.CoreProperties // You can read properties from the document fmt.Println("Title:", cp.Title()) fmt.Println("Author:", cp.Author()) fmt.Println("Description:", cp.Description()) fmt.Println("Last Modified By:", cp.LastModifiedBy()) fmt.Println("Category:", cp.Category()) fmt.Println("Content Status:", cp.ContentStatus()) fmt.Println("Created:", cp.Created()) fmt.Println("Modified:", cp.Modified()) // And change them as well cp.SetTitle("CP Invoices") cp.SetAuthor("John Doe") cp.SetCategory("Invoices") cp.SetContentStatus("Draft") cp.SetLastModifiedBy("Jane Smith") cp.SetCreated(time.Now()) cp.SetModified(time.Now()) doc.SaveToFile("document_modified.docx") }