-
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.
[7.6.0][CDE] ApiUniColor.ToJSON check (#1015)
* feature: ApiUniColor.ToJSON * ref: ApiUniColor.ToJSON * ref: ApiUniColor.ToJSON * ref: ApiUniColor.ToJSON * ref: ApiUniColor.ToJSON
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
builder.CreateFile("docx"); | ||
let oDocument = Api.GetDocument(); | ||
let oParagraph = oDocument.GetElement(0); | ||
// RGBColor is an inheritor of UniColor class. | ||
// It is impossible to use an instance of UniColor class directly | ||
let oRGBColor = Api.CreateRGBColor(255, 111, 61); | ||
let oFill = Api.CreateSolidFill(oRGBColor); | ||
oParagraph.AddText(oFill.ToJSON()); | ||
GlobalVariable["JSON_UniColor"] = oFill.ToJSON(); | ||
builder.CloseFile(); | ||
|
||
///////////////////// | ||
|
||
builder.CreateFile("docx"); | ||
let oDocument = Api.GetDocument(); | ||
let oParagraph = oDocument.GetElement(0); | ||
let jsonSolidFill = GlobalVariable["JSON_UniColor"]; | ||
let oFillRestored = Api.FromJSON(jsonSolidFill); | ||
let oStroke = Api.CreateStroke(0, Api.CreateNoFill()); | ||
let oDrawing = Api.CreateShape("rect", 5930900, 395605, oFillRestored, oStroke); | ||
let jsonDrawing = oDrawing.ToJSON(false, true); | ||
oParagraph.AddText(jsonDrawing); | ||
oDocument.Push(oParagraph); | ||
builder.SaveFile("docx", "UnicolorToJson.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