mirror of
https://github.com/unidoc/unioffice.git
synced 2025-04-27 13:48:54 +08:00
40 lines
957 B
Go
40 lines
957 B
Go
// Copyright 2017 FoxyUtils ehf. All rights reserved.
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"time"
|
|
|
|
"github.com/unidoc/unioffice/document"
|
|
)
|
|
|
|
func main() {
|
|
doc, err := document.Open("document.docx")
|
|
if err != nil {
|
|
log.Fatalf("error opening document: %s", err)
|
|
}
|
|
|
|
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.docx")
|
|
}
|