Vyacheslav Zgordan 6cbaf67f9e
Validating examples (#404)
* only input files remain, output deleted

* example changed to produce a new file instead of modifying the old one

* source document with incorrect characterSet is fixed; ppt path is fixed; invalid strict example is removed

* Ignorable attributes added for validating newer versions of Office

* indentation fix

* 4 byte values for rgb attr

* Validate examples in travis

* indentation

* travis files moved to subfolder

* fixed and renamed validate-examples.sh

* avoiding double building

* Update .travis.yml

* Fix indent

Co-authored-by: Gunnsteinn Hall <gunnsteinn.hall@gmail.com>
2020-06-17 21:43:35 +00:00

40 lines
966 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_modified.docx")
}