Do you want to: Report a bug
Problem: I’m trying to get the JSON structure of the document from Docbuilder and then use that json to build up the document again. However, in certain cases, it throws the following errors.
app.js:8 Uncaught TypeError: Cannot read properties of undefined (reading ‘toString’)
at Object.getHexColor (app.js:8:327739)
Here is the code that I m using:
let json = oDocument.ToJSON(true, true, false, true, true, true);
var oDocument = Api.GetDocument();
oDocument.RemoveAllElements();
var oDocumentFromJSON = Api.FromJSON(json);
for(var i=0; i < oDocumentFromJSON.length;i++){
oDocument.AddElement(i, oDocumentFromJSON[i]);
}
The problems comes from the following functions
`AscWord.CTextPr.prototype.FromJson` & `AscWord.CTextPr.prototype.ToJson`
with the key argument “color”. In fact when doing ToJson, the “color” value can end up being an empty dictionary. But when doing FromJson, it checks if “color” != null, then it tries to access the values that are undefined. I guess the “highlight” key argument has the same issue.
Best,
DocumentBuilder version:
Installation method: docker image: onlyoffice/documentserver:7.3.2.8