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.

builder.OpenFile(“c:\in_file.docx”);
var oDocument = Api.GetDocument();
oDocument.SearchAndReplace({“searchString”: “”, “replaceString”: “text1”});
var oParagraph = Api.CreateParagraph();
oDocument.Push(oParagraph);
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();
oTextPr.SetFontSize(28);
oTable.GetRow(0).SetTextPr(oTextPr);
var oCell = oTable.GetRow(0).GetCell(0);
oCell.GetContent().GetElement(0).AddText(“text2”);
var oCell = oTable.GetRow(0).GetCell(2);
oCell.GetContent().GetElement(0).AddText(“text3”);
oTable.AddRow();
oTable.AddRow();
oTable.AddRow();
var oTextPr = oDocument.GetDefaultTextPr();
oTextPr.SetFontSize(20);
oTable.GetRow(2).SetTextPr(oTextPr);
var oCell = oTable.GetRow(2).GetCell(0);
oCell.GetContent().GetElement(0).AddText(“text4”);
oDocument.Push(oTable);
oTable.SetWidth(“percent”, 100);
builder.SaveFile(“docx”,“c:\out_file.docx”);
builder.CloseFile();

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

oTextPr.SetFontSize(28);

What I’m doing wrong?
Thanks.

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.

https://drive.google.com/file/d/19mQqCDigV6DGp4rmrMh4QP2AG5By3jM8/view?usp=drivesdk

https://drive.google.com/file/d/19mQqCDigV6DGp4rmrMh4QP2AG5By3jM8/view?usp=drivesdk

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.

Checked.
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.