Todd 09825ac816 schema: rework schema namespaces to work around Windows issues
The go command on Windows doesn't like long path name. To
work around this, this is the first in a series of changes to
shorten the schema disk path structure in a few places.

Fixes #89
2017-09-23 10:01:17 -04:00

47 lines
1.3 KiB
Go

// Copyright 2017 Baliance. All rights reserved.
package main
import (
"log"
"baliance.com/gooxml/common"
"baliance.com/gooxml/document"
"baliance.com/gooxml/measurement"
wml "baliance.com/gooxml/schema/soo/wordprocessingml"
)
var lorem = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin lobortis, lectus dictum feugiat tempus, sem neque finibus enim, sed eleifend sem nunc ac diam. Vestibulum tempus sagittis elementum`
func main() {
doc := document.New()
img, err := common.ImageFromFile("gophercolor.png")
if err != nil {
log.Fatalf("unable to create image: %s", err)
}
iref, err := doc.AddImage(img)
if err != nil {
log.Fatalf("unable to add image to document: %s", err)
}
para := doc.AddParagraph()
anchored, err := para.AddRun().AddDrawingAnchored(iref)
if err != nil {
log.Fatalf("unable to add anchored image: %s", err)
}
anchored.SetName("Gopher")
anchored.SetSize(2*measurement.Inch, 2*measurement.Inch)
anchored.SetOrigin(wml.WdST_RelFromHPage, wml.WdST_RelFromVTopMargin)
anchored.SetHAlignment(wml.WdST_AlignHCenter)
anchored.SetYOffset(3 * measurement.Inch)
anchored.SetTextWrapSquare(wml.WdST_WrapTextBothSides)
run := para.AddRun()
for i := 0; i < 16; i++ {
run.AddText(lorem)
}
doc.SaveToFile("image.docx")
}