Meet ONLYOFFICE Docs Cloud, complete office software as a service
Meet ONLYOFFICE Docs Cloud

ApiText question: SetTextPr doens't work on a desired table row

DocumentBuilder version: 7.1.1
Installation method: docbuilder.exe
OS: Windows 7 x64
Here is the code.

var oDocument = Api.GetDocument();
oDocument.SearchAndReplace({“searchString”: “”, “replaceString”: “text1”});
var oParagraph = Api.CreateParagraph();
var oTable = Api.CreateTable(3, 1);
var oCell = oTable.GetRow(0).GetCell(0);
oCell.SetWidth(“twips”, 4200);
var oCell = oTable.GetRow(0).GetCell(1);
oCell.SetWidth(“twips”, 1200);
var oTextPr = oDocument.GetDefaultTextPr();
var oCell = oTable.GetRow(0).GetCell(0);
var oCell = oTable.GetRow(0).GetCell(2);
var oTextPr = oDocument.GetDefaultTextPr();
var oCell = oTable.GetRow(2).GetCell(0);
oTable.SetWidth(“percent”, 100);

text4 doesn’t get a TextPr FontSize 20, it left TextPr from this


What I’m doing wrong?

Hello @poddex
Do I understand it right that you are using pre-made file which already contains some data (in_file.docx) in this scenario? Could you please share this file with us? Also please reproduce the issue and provide us with issue screenshots (step-by-step).

Yes, it’s a pre-made template.
in_file is a template. It structure is the same as real doc, I replaced some text to “xxx” for easy debug and because of security.
In out_file “text4” in a table created at the end of file should has fontsize 10(20), but it has 14(28)., other cells in this row (2) has 10(20), but only cells. Text4 doesn’t get TextPr with fontsize 10(20), I don’t know why.
Here is the link to all attachments.

Sorry, I don’t have access to attachments. Please provide us with download link.

Thank you for files, we are checking the situation.

Hello @poddex
Sorry for the late reply. It took us some time to check.
Could you please reproduce the situation with DocBuilder v.7.2. It seems that the issue doesn’t persist on the latest version.

Text4 left with 28 fontsize.
Code doesn’t work. Maybe, error in a code? Can’t find it, as I see in examples - code must work properly. In a picture: cells after first cell became 10(20) fontsize (it’s right), but first cell with text4 still 14(28) - but it should get 10(20) because TextPr applies to the entire row.

We double-checked the situation and I believe we figured out the situation. The GetDefaultTextPr contains incorrect example in API knowledge base, we are going to change it.
I can’t attach changed .docbuilder file to the post, so I’ll send it to you in PM in a few minutes

It works. Thanks.

Crap. Found an issue in Docbuilder 7.2.
This line
oDocument.SearchAndReplace({“searchString”: “”, “replaceString”: “text1”});
causes alll text to be a bold. 7.1.1 works fine. But 7.1.1 doesn’t have api.createtextpr() function. Any ideas?

All files attached here

Hello @poddex
Thank you for the file and script, we are checking the situation.

Hello @poddex
thank you for pointing us to this situation. We have reproduced it and we added a bug to internal tracksystem (internal number - 59329). We have started working on it.

Thanks, I’m waiting.