-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from unidoc/rc-v1.12.0
Rc v1.12.0
- Loading branch information
Showing
13 changed files
with
339 additions
and
4 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ func init() { | |
} | ||
|
||
var filenames = []string{ | ||
"chart", | ||
"headers_footers", | ||
"image_square", | ||
"table", | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
// Copyright 2017 FoxyUtils ehf. All rights reserved. | ||
package main | ||
|
||
import ( | ||
"io/ioutil" | ||
"log" | ||
|
||
"github.com/unidoc/unioffice/common" | ||
"github.com/unidoc/unioffice/common/license" | ||
"github.com/unidoc/unioffice/document" | ||
"github.com/unidoc/unioffice/measurement" | ||
|
||
"github.com/unidoc/unioffice/schema/soo/wml" | ||
) | ||
|
||
const licenseKey = ` | ||
-----BEGIN UNIDOC LICENSE KEY----- | ||
Free trial license keys are available at: https://unidoc.io/ | ||
-----END UNIDOC LICENSE KEY----- | ||
` | ||
|
||
func init() { | ||
err := license.SetLicenseKey(licenseKey, `Company Name`) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
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() | ||
defer doc.Close() | ||
|
||
img1, err := common.ImageFromFile("gophercolor.png") | ||
if err != nil { | ||
log.Fatalf("unable to create image: %s", err) | ||
} | ||
img2data, err := ioutil.ReadFile("gophercolor.png") | ||
if err != nil { | ||
log.Fatalf("unable to read file: %s", err) | ||
} | ||
img2, err := common.ImageFromBytes(img2data) | ||
if err != nil { | ||
log.Fatalf("unable to create image: %s", err) | ||
} | ||
|
||
img1ref, err := doc.AddImage(img1) | ||
if err != nil { | ||
log.Fatalf("unable to add image to document: %s", err) | ||
} | ||
img2ref, err := doc.AddImage(img2) | ||
if err != nil { | ||
log.Fatalf("unable to add image to document: %s", err) | ||
} | ||
|
||
para := doc.AddParagraph() | ||
anchored, err := para.AddRun().AddDrawingAnchored(img1ref) | ||
if err != nil { | ||
log.Fatalf("unable to add anchored image: %s", err) | ||
} | ||
|
||
// Drop square text wrap image. | ||
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 < 40; i++ { | ||
run.AddText(lorem) | ||
|
||
// drop an inline image in | ||
if i == 13 { | ||
inl, err := run.AddDrawingInline(img1ref) | ||
if err != nil { | ||
log.Fatalf("unable to add inline image: %s", err) | ||
} | ||
inl.SetSize(1*measurement.Inch, 1*measurement.Inch) | ||
} | ||
|
||
// Drop image behind text. | ||
if i == 18 { | ||
anchorDraw, err := run.AddDrawingAnchored(img2ref) | ||
if err != nil { | ||
log.Fatalf("unable to add behind text image: %s", err) | ||
} | ||
anchorDraw.SetTextWrapBehindText() | ||
anchorDraw.SetOrigin(wml.WdST_RelFromHColumn, wml.WdST_RelFromVParagraph) | ||
anchorDraw.SetHAlignment(wml.WdST_AlignHUnset) | ||
anchorDraw.SetOffset(2*measurement.Inch, 3*measurement.Inch) | ||
anchorDraw.SetSize(1*measurement.Inch, 1*measurement.Inch) | ||
} | ||
|
||
// Drop image in front of text. | ||
if i == 21 { | ||
anchorDraw, err := run.AddDrawingAnchored(img2ref) | ||
if err != nil { | ||
log.Fatalf("unable to add in front of text image: %s", err) | ||
} | ||
anchorDraw.SetTextWrapInFrontOfText() | ||
anchorDraw.SetOrigin(wml.WdST_RelFromHColumn, wml.WdST_RelFromVParagraph) | ||
anchorDraw.SetHAlignment(wml.WdST_AlignHUnset) | ||
anchorDraw.SetOffset(5*measurement.Inch, 4*measurement.Inch) | ||
anchorDraw.SetSize(1*measurement.Inch, 1*measurement.Inch) | ||
} | ||
|
||
// Drop image with bottom and top wrap text. | ||
if i == 23 { | ||
anchorDraw, err := run.AddDrawingAnchored(img2ref) | ||
if err != nil { | ||
log.Fatalf("unable to add top and bottom wrap text image: %s", err) | ||
} | ||
anchorDraw.SetTextWrapTopAndBottom() | ||
anchorDraw.SetOrigin(wml.WdST_RelFromHColumn, wml.WdST_RelFromVParagraph) | ||
anchorDraw.SetHAlignment(wml.WdST_AlignHCenter) | ||
anchorDraw.SetYOffset(7 * measurement.Inch) | ||
anchorDraw.SetSize(1*measurement.Inch, 1*measurement.Inch) | ||
} | ||
|
||
// Drop image with through wrap text. | ||
if i == 27 { | ||
anchorDraw, err := run.AddDrawingAnchored(img2ref) | ||
if err != nil { | ||
log.Fatalf("unable to add through wrap text image: %s", err) | ||
} | ||
// Create anchor draw option, parameter for options is followImageShape true or false. | ||
anchorDrawOption := document.NewAnchorDrawWrapOptions() | ||
anchorDraw.SetTextWrapThrough(anchorDrawOption) | ||
anchorDraw.SetOrigin(wml.WdST_RelFromHPage, wml.WdST_RelFromVParagraph) | ||
anchorDraw.SetOffset(2*measurement.Inch, 3*measurement.Inch) | ||
anchorDraw.SetSize(1*measurement.Inch, 1*measurement.Inch) | ||
} | ||
|
||
// Drop image with tight wrap text. | ||
if i == 30 { | ||
anchorDraw, err := run.AddDrawingAnchored(img2ref) | ||
if err != nil { | ||
log.Fatalf("unable to add tight wrap text image: %s", err) | ||
} | ||
// Create anchor draw option, parameter for options is followImageShape true or false. | ||
anchorDrawOption := document.NewAnchorDrawWrapOptions() | ||
anchorDraw.SetTextWrapTight(anchorDrawOption) | ||
anchorDraw.SetOrigin(wml.WdST_RelFromHPage, wml.WdST_RelFromVParagraph) | ||
anchorDraw.SetOffset(5*measurement.Inch, 2*measurement.Inch) | ||
anchorDraw.SetSize(1*measurement.Inch, 1*measurement.Inch) | ||
} | ||
} | ||
doc.SaveToFile("image-text-wrap.docx") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2017 FoxyUtils ehf. All rights reserved. | ||
package main | ||
|
||
import ( | ||
"github.com/unidoc/unioffice/common/license" | ||
"github.com/unidoc/unioffice/document" | ||
"github.com/unidoc/unioffice/measurement" | ||
"github.com/unidoc/unioffice/schema/soo/wml" | ||
) | ||
|
||
const licenseKey = ` | ||
-----BEGIN UNIDOC LICENSE KEY----- | ||
Free trial license keys are available at: https://unidoc.io/ | ||
-----END UNIDOC LICENSE KEY----- | ||
` | ||
|
||
func init() { | ||
err := license.SetLicenseKey(licenseKey, `Company Name`) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
func main() { | ||
doc := document.New() | ||
defer doc.Close() | ||
|
||
// Create paragraph and apply Title style to paragraph. | ||
para := doc.AddParagraph() | ||
run := para.AddRun() | ||
para.SetStyle("Title") | ||
run.AddText("What is Lorem Ipsum?") | ||
|
||
// Create paragraph and apply Heading1 style to paragraph. | ||
para = doc.AddParagraph() | ||
para.SetStyle("Heading1") | ||
run = para.AddRun() | ||
run.AddText("Lorem Ipsum is simply dummy text of the printing and typesetting industry.") | ||
|
||
// Set page size to paper A4 and orientation to landscape. | ||
// Paper A4 size is 8.3" × 11.7". | ||
// You can set the orientation with wml.ST_PageOrientationLandscape or wml.ST_PageOrientationPortrait, | ||
section := doc.BodySection() | ||
section.SetPageSizeAndOrientation(measurement.Inch*8.3, measurement.Inch*11.7, wml.ST_PageOrientationLandscape) | ||
|
||
doc.SaveToFile("page-size-and-orientation.docx") | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2017 FoxyUtils ehf. All rights reserved. | ||
package main | ||
|
||
import ( | ||
"github.com/unidoc/unioffice/common/license" | ||
"github.com/unidoc/unioffice/document" | ||
"github.com/unidoc/unioffice/measurement" | ||
"github.com/unidoc/unioffice/schema/soo/wml" | ||
) | ||
|
||
const licenseKey = ` | ||
-----BEGIN UNIDOC LICENSE KEY----- | ||
Free trial license keys are available at: https://unidoc.io/ | ||
-----END UNIDOC LICENSE KEY----- | ||
` | ||
|
||
func init() { | ||
err := license.SetLicenseKey(licenseKey, `Company Name`) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
func main() { | ||
doc := document.New() | ||
defer doc.Close() | ||
|
||
// Create paragraph and apply Title style to paragraph. | ||
para := doc.AddParagraph() | ||
run := para.AddRun() | ||
para.SetStyle("Title") | ||
run.AddText("What is Lorem Ipsum?") | ||
|
||
// Create paragraph and apply Heading1 style to paragraph. | ||
para = doc.AddParagraph() | ||
para.SetStyle("Heading1") | ||
run = para.AddRun() | ||
run.AddText("Lorem Ipsum is simply dummy text of the printing and typesetting industry.") | ||
|
||
// Create custom style named CustomStyle1 for paragraph style. | ||
// Set last boolean parameter to TRUE if you want to make it default for paragraph. | ||
style := doc.Styles | ||
customStyle := style.AddStyle("CustomStyle1", wml.ST_StyleTypeParagraph, false) | ||
customStyle.SetName("Custom Style 1") | ||
// Set spacing of paragraph before and after. | ||
customStyle.ParagraphProperties().SetSpacing(measurement.Inch*1, measurement.Inch*1) | ||
customStyle.ParagraphProperties().SetAlignment(wml.ST_JcBoth) | ||
customStyle.ParagraphProperties().SetFirstLineIndent(measurement.Inch * 2) | ||
// Set line spacing to single, in this case, 12 points is text height. | ||
customStyle.ParagraphProperties().SetLineSpacing(12*measurement.Point, wml.ST_LineSpacingRuleAuto) | ||
// Apply style `CustomStyle1` to paragraph. | ||
para = doc.AddParagraph() | ||
para.SetStyle("CustomStyle1") | ||
run = para.AddRun() | ||
run.AddText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.") | ||
|
||
doc.SaveToFile("paragraph-style.docx") | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters