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

Carl
Posts: 396
Joined: Thu Apr 12, 2018 10:00 am

Re: DocumentBuilder SearchAndReplace

Post by Carl » Tue Mar 31, 2020 7:45 am

Hello,

You are using some old version of Document Builder. The Search and Replace method is not available in this version. Please install the current Document Server version 5.5 and use the Document Builder available there:
https://api.onlyoffice.com/editors/documentbuilderapi

Post Reply