DocumentBuilder SearchAndReplace

Post Reply
goofy
Posts: 1
Joined: Wed Mar 25, 2020 9:28 am

DocumentBuilder SearchAndReplace

Post by goofy » Wed Mar 25, 2020 9:35 am

I'm using DocumentBuilder 4.4.1
I'm trying modify a existing docx document to modify some text
In this cas i want to remplace teh text "TOTO" by "TITI"
So this my code :

Code: Select all

builder.OpenFile("sample1.docx");        

var oDocument = Api.GetDocument();
oDocument.SearchAndReplace(oDocument,"TOTO","TITI");

builder.SaveFile("docx", "./TESTFILES/test.docx");   // save the resulting text document as a file in the .docx format with a new 'example.docx' name
builder.CloseFile(); 
There is a error :
execute_run_code: oDocument.SearchAndReplace(oDocument,"TOTO","TITI");
execute_run: Uncaught TypeError: oDocument.SearchAndReplace is not a function
in https://api.onlyoffice.com/docbuilder/t ... andreplace i saw :
SearchAndReplace(oProperties, oProperties.searchString, oProperties.replaceString, [oProperties.matchCase])

the function exists but what is oPropertie ?
Can yoi help me ?
thanks

Post Reply