Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when transferring oTextPr object via GlobalVariable #86

Open
PaSen-pzk opened this issue Jul 14, 2022 · 5 comments
Open

Error when transferring oTextPr object via GlobalVariable #86

PaSen-pzk opened this issue Jul 14, 2022 · 5 comments
Labels
confirmed-bug Issues with confirmed bugs

Comments

@PaSen-pzk
Copy link

PaSen-pzk commented Jul 14, 2022

Integrate ONLYOFFICE Document Builder into my application on Node.js. Using globalvariable method to create paragraph object will cause errors.
Steps to reproduce the problem:
Exception Info:

Uncaught TypeError: Converting circular structure to JSON
--> starting at object with constructor 'cb'
--- property 'va' closes the circle

Script example:

builder.OpenFile("2022072-10000-81acb5fcd08244e3926c891263cfe168.docx");
var tempDocument = Api.GetDocument();
var tempDocumentParagraphs= tempDocument.GetElement(0);
GlobalVariable[ "CommentsReport" ] = tempDocumentParagraphs;
builder.CloseFile();
builder.OpenFile("2022072-10000-99c8b7f2ef844e97b6410eee0b0618c2.docx");
var curDocument = Api.GetDocument();
var oParagraph = Api.CreateParagraph();
var tempParagraph = global;
oParagraph.InsertParagraph(tempParagraph, "after" , true );
curDocument.Push(oParagraph); 
builder.SaveFile("docx", "Result4.docx");
builder.CloseFile();

Execution mode:
Run the above script with the executable file of docbuilder under the onlyoffice installation directory.
DocumentBuilder version:
Version: 7.1.1
Installation method:
Download and unpack on Windows .
Operating system:
Windows11

@ShockwaveNN
Copy link
Contributor

Hi, I think we need both those files to correctly diagnose the situation
"2022072-10000-81acb5fcd08244e3926c891263cfe168.docx"
"2022072-10000-99c8b7f2ef844e97b6410eee0b0618c2.docx"

@PaSen-pzk
Copy link
Author

2022072-10000-81acb5fcd08244e3926c891263cfe168.docx
2022072-10000-99c8b7f2ef844e97b6410eee0b0618c2.docx

@l8556
Copy link
Member

l8556 commented Jul 14, 2022

Hello @PaSen-pzk !
You are not using GlobalVariable correctly.

Example of correct usage:

builder.OpenFile("2022072-10000-81acb5fcd08244e3926c891263cfe168.docx");
var oDocument = Api.GetDocument();
GlobalVariable["CommentsReport"] = oDocument.GetElement(0).GetText();
builder.CloseFile();

builder.OpenFile("2022072-10000-99c8b7f2ef844e97b6410eee0b0618c2.docx");
var oCommentsReport = GlobalVariable["CommentsReport"];
var oDocument = Api.GetDocument();
var oParagraph = Api.CreateParagraph();
oParagraph.InsertParagraph(oCommentsReport, "after", true);
builder.SaveFile("docx", "Result.docx");
builder.CloseFile();

@PaSen-pzk
Copy link
Author

你好@PaSen-pzk! 您没有正确使用 GlobalVariable。

正确用法示例:

builder.OpenFile("2022072-10000-81acb5fcd08244e3926c891263cfe168.docx");
var oDocument = Api.GetDocument();
GlobalVariable["CommentsReport"] = oDocument.GetElement(0).GetText();
builder.CloseFile();

builder.OpenFile("2022072-10000-99c8b7f2ef844e97b6410eee0b0618c2.docx");
var oCommentsReport = GlobalVariable["CommentsReport"];
var oDocument = Api.GetDocument();
var oParagraph = Api.CreateParagraph();
oParagraph.InsertParagraph(oCommentsReport, "after", true);
builder.SaveFile("docx", "Result.docx");
builder.CloseFile();

In this case, there is no guarantee that the merged content format is consistent with the source file. In the way you provided, I tried to get the text format, that is, apitextpr, and add it to the global variable, but the function contained in this apitextpr object cannot be serialized, so it is not available.

@l8556
Copy link
Member

l8556 commented Jul 15, 2022

你好@PaSen-pzk! 您没有正确使用 GlobalVariable。
正确用法示例:

builder.OpenFile("2022072-10000-81acb5fcd08244e3926c891263cfe168.docx");
var oDocument = Api.GetDocument();
GlobalVariable["CommentsReport"] = oDocument.GetElement(0).GetText();
builder.CloseFile();

builder.OpenFile("2022072-10000-99c8b7f2ef844e97b6410eee0b0618c2.docx");
var oCommentsReport = GlobalVariable["CommentsReport"];
var oDocument = Api.GetDocument();
var oParagraph = Api.CreateParagraph();
oParagraph.InsertParagraph(oCommentsReport, "after", true);
builder.SaveFile("docx", "Result.docx");
builder.CloseFile();

In this case, there is no guarantee that the merged content format is consistent with the source file. In the way you provided, I tried to get the text format, that is, apitextpr, and add it to the global variable, but the function contained in this apitextpr object cannot be serialized, so it is not available.

This is a bug. Issue 58126 in our private issue tracker.

@ShockwaveNN ShockwaveNN added the confirmed-bug Issues with confirmed bugs label Jul 15, 2022
@ShockwaveNN ShockwaveNN changed the title Using globalvariable method to create paragraph object will cause errors. Error when transferring oTextPr object via GlobalVariable Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs
Projects
None yet
Development

No branches or pull requests

3 participants