We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

FitText in WordDocument do not refresh

Hello,
i add a Table to new word document. then i modify the cell with "TextWarp" and "FitText" but afte opend the word document the text in cells arent fitted.
When i focus the row the text fits.
Is there any problem?
My code:
foreach (XmlTemplate.TableRow tableRow in xmlTemplate.TableRows)
{
if (tableRow.Type.CompareTo("Header") == 0)
{

Debug.WriteLine("Add ROW");
WTableRow row = wTable.AddRow();
row.Height = GetCmToFloat(Convert.ToDecimal(0.875));
row.IsHeader = true;
row.HeightType = TableRowHeightType.Exactly;
foreach (XmlTemplate.Cell cell in tableRow.CellsList)
{
WTableCell wTableCell = row.AddCell();
wTableCell.Width = GetCmToFloat(cell.Width);

IWTextRange wTextRange = wTableCell.AddParagraph().AppendText(cell.Text);

wTextRange.CharacterFormat.FontName = string.IsNullOrEmpty(cell.Font) ? "Arial" : cell.Font;
wTextRange.CharacterFormat.FontSize = cell.FontSize;
wTextRange.CharacterFormat.Bold = true;
if (!string.IsNullOrWhiteSpace(cell.Halignment))
{
wTextRange.OwnerParagraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
}
}
}
}
....
IWSection wSection = wordDocument.Sections[0];
IWTable wTable = wSection.Tables[0];
for (int i = 0; i <= wTable.Rows.Count - 1; i++)
{
WTableRow row = wTable.Rows[i];
List cellList = xmlTemplate.TableRows[i].CellsList;
for (int j = 0; j <= row.Cells.Count - 1; j++)
{
XmlTemplate.Cell cell = cellList[j];
WTableCell wTableCell = row.Cells[j];
wTableCell.CellFormat.SamePaddingsAsTable = false;
wTableCell.Width = GetCmToFloat(cell.Width);
if (cell.CellMargin != null)
{

wTableCell.CellFormat.Paddings.Left = GetCmToFloat(cell.CellMargin.Left);
wTableCell.CellFormat.Paddings.Right = GetCmToFloat(cell.CellMargin.Right);

}
else
{

wTableCell.CellFormat.Paddings.Left = GetCmToFloat(Convert.ToDecimal(0.1));

}
wTableCell.CellFormat.TextWrap = cell.IsTextWarp;
wTableCell.CellFormat.FitText = cell.IsTextWarp;

wTableCell.CellFormat.Borders.BorderType = BorderStyle.Single;
wTableCell.CellFormat.Borders.LineWidth = 1;
wTableCell.CellFormat.VerticalAlignment = VerticalAlignment.Middle;
wTableCell.CellFormat.HorizontalMerge = CellMerge.Start;
wTableCell.CellFormat.BackColor = Color.LightGray;

}
}
Christian

2 Replies

MJ Mohanaselvam Jothi Syncfusion Team July 9, 2019 02:18 PM UTC

Hi Christian,

Thank you for contacting Syncfusion support.

We can reproduce the reported text preservation problem in table in the Word document. We have faced conflicts (dependent code example missing) in the given code snippets. So, we have modified the code snippet to make runnable. Please find the sample which we tried at our end from the below link:
https://www.syncfusion.com/downloads/support/forum/145803/ze/CreateWordSample538545617

Please refer the below screenshot of generated Word document using above sample. 
After opened the generated Word document 
When focusing on not fitted text. 
 
 

On further checking with the reported problem, we have found after focusing on the particular text Microsoft Word viewer preserves the text properly in visual appearance and not found any changes in the file level for this preservation changes. This is not an issue in DocIO and it is problem when rendering contents by Word viewer.

Please let us know if you have any other questions.

Regards,
Mohanaselvam J



PR Poorani Rajendran Syncfusion Team July 9, 2019 02:57 PM UTC

Hi Christian,

Please ignore our previous update.

We can reproduce the reported text preservation problem in table in the Word document. We have faced conflicts (dependent code example missing) in the given code snippets. So, we have modified the code snippet to make runnable. Please find the sample which we tried at our end from the below link:
https://www.syncfusion.com/downloads/support/forum/145803/ze/CreateWordSample538545617

Please refer the below screenshot of generated Word document using above sample. 
After opened the generated Word document 
When focusing on not fitted text. 
 
 

On further checking with the reported problem, we have found after focusing on the particular text Microsoft Word viewer preserves the text properly in visual appearance and not found any changes in the file level for this preservation changes. This is not an issue in DocIO and it is problem when rendering contents by Word viewer.

Please let us know if you have any other questions.

Regards,
Poorani Rajendran 




Loader.
Live Chat Icon For mobile
Up arrow icon