-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
41 additions
and
34 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,28 +1,40 @@ | ||
builder.CreateFile("docx"); | ||
let oDocument = Api.GetDocument(); | ||
let oParagraph = oDocument.GetElement(0); | ||
let oRGBColor = Api.CreateRGBColor(255, 111, 61); | ||
let oStroke = Api.CreateStroke(5 * 36000, Api.CreateSolidFill(Api.CreateRGBColor(51, 51, 51))); | ||
let jsonStroke = oStroke.ToJSON(); | ||
oParagraph.AddText(jsonStroke); | ||
GlobalVariable["JSON_Stroke"] = jsonStroke; | ||
var oGs1 = Api.CreateGradientStop(Api.CreateRGBColor(255, 213, 191), 0); | ||
var oGs2 = Api.CreateGradientStop(Api.CreateRGBColor(255, 111, 61), 100000); | ||
var arr = [] | ||
arr.push(Api.CreateBlipFill("https://api.onlyoffice.com/content/img/docbuilder/examples/icon_DocumentEditors.png", "tile")); | ||
arr.push(Api.CreateSolidFill(Api.CreateRGBColor(102, 0, 204))) | ||
arr.push(Api.CreateLinearGradientFill([oGs1, oGs2], 5400000)) | ||
arr.push(Api.CreateNoFill()) | ||
arr.push(Api.CreatePatternFill("cross", Api.CreateRGBColor(255, 111, 61), Api.CreateRGBColor(51, 51, 51))) | ||
arr.push(Api.CreateRadialGradientFill([oGs1, oGs2])) | ||
arr = arr.map((fill) => { | ||
var oStroke = Api.CreateStroke(10 * 36000, fill); | ||
return oStroke.ToJSON() | ||
}) | ||
GlobalVariable["arrStroke"] = arr; | ||
builder.CloseFile(); | ||
|
||
////////////////////// | ||
|
||
builder.CreateFile("docx"); | ||
let oDocument = Api.GetDocument(); | ||
let oParagraph = oDocument.GetElement(0); | ||
let jsonStroke = GlobalVariable["JSON_Stroke"]; | ||
let oRGBColor2 = Api.CreateRGBColor(255, 213, 191); | ||
let oFill = Api.CreateSolidFill(oRGBColor2); | ||
let oStrokeFromJSON = Api.FromJSON(jsonStroke); | ||
let oDrawing = Api.CreateShape("roundRect", 5930900, 395605, oFill, oStrokeFromJSON); | ||
oParagraph.AddDrawing(oDrawing); | ||
let oParagraph2 = Api.CreateParagraph(); | ||
let jsonDrawing = oDrawing.ToJSON(false, true); | ||
oParagraph2.AddText(jsonDrawing); | ||
oDocument.Push(oParagraph2); | ||
var arrStroke = GlobalVariable["arrStroke"]; | ||
arrStroke.forEach((stroke) => { | ||
var odoc = Api.GetDocument(); | ||
var opar = Api.CreateParagraph(); | ||
opar.AddText(stroke) | ||
odoc.Push(opar) | ||
}) | ||
arrStroke.forEach((stroke) => { | ||
var oStroke = Api.FromJSON(stroke); | ||
var odoc = Api.GetDocument(); | ||
var opar = Api.CreateParagraph(); | ||
var oGs1 = Api.CreateGradientStop(Api.CreateRGBColor(255, 213, 191), 0); | ||
var oGs2 = Api.CreateGradientStop(Api.CreateRGBColor(255, 111, 61), 100000); | ||
var oFill = Api.CreateRadialGradientFill([oGs1, oGs2]); | ||
var oDrawing = Api.CreateShape("star10", 10000 * 593, 10000 * 590, oFill, oStroke); | ||
opar.AddDrawing(oDrawing); | ||
odoc.Push(opar); | ||
}); | ||
builder.SaveFile("docx", "StrokeToJson.docx"); | ||
builder.CloseFile(); | ||
|
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