Attempt to call multiple times “plugin → Paragraph.InsertParagraph” method resulted in an error
Hello @zazatyty
Are you using Document Server or Desktop Editor? What is the version of the app?
Can you also share more context to the for
function? As I can see it uses currentParagraph
variable, but it is not clear what it is actually.
Reply 1:using Document Server
Reply 2:the version is 8.2.2 (build:22)
Reply 3:
More context to the for function:Used plugins, Exception occurs when adding more than a few paragraphs
This usage also reports an error, as long as multiple paragraphs are created and inserted, an error will be reported
These are approaches are incorrect. InsertContent
works with a single para and Push
must be used on the document level. Here is working example:
var oDocument = Api.GetDocument();
var oParagraph0 = oDocument.GetElement(0);
oParagraph0.AddText("This is paragraph #0, you must not push it to take effect.");
for (let nParaIncrease = 0; nParaIncrease < 5; ++nParaIncrease) {
var oParagraph = Api.CreateParagraph();
oParagraph.AddText("This is paragraph #" + (nParaIncrease + 1) + ", you must push it to take effect.");
oDocument.Push(oParagraph);
}