Hi,
I'm trying to insert few paragraphs in table cells and my text is not looking correct. Could you please help me? I'm using latest Spire nuget with C#.net
If I dont load the template, my paragraphs are looking fine, however with my template, they wont work.
- Code: Select all
var doc = new SP.Document();
var fileName1 = "1.0.0.docx";
doc.LoadFromFile("My path here");
doc.AddSection();
var table = doc.LastSection.AddTable(false);
table.PreferredWidth = new SP.PreferredWidth(SP.WidthType.Percentage, 100);
CharacterFormat format = new CharacterFormat(doc);
if (mylang == "Arabic")
{
format.Bidi = true;
}
var stringValues = new List<string> {"Testing the titles as is giving few problems so keeping long test values for demo and test purposes please make sure the content remains same and dont change anything",
"Testing the titles as is giving few problems so keeping long test values for demo and test purposes please make sure the content remains same and dont change anything",
"Executive Board of our Organizations Development Programme/Other fund related stuff/Our Office for Project Services "};
foreach (var string1 in stringValues)
{
var row = table.AddRow(false, 4);
row.RowFormat.BackColor = Color.White;
var paragraph = row.Cells[0].AddParagraph();
TextRange range = paragraph.AppendText(string1);
range.CharacterFormat.FontName = "Times New Roman";
range.CharacterFormat.FontSize = 16;
range.CharacterFormat.Bold = true;
paragraph.Format.HorizontalAlignment = HorizontalAlignment.Left;
TextRange range1 = paragraph.AppendText(" - " + "my test value");
range1.CharacterFormat.FontName = "Times New Roman";
range1.CharacterFormat.FontSize = 15;
range1.CharacterFormat.TextColor = Color.FromArgb(89, 89, 89);
range1.CharacterFormat.Bold = true;
table.ApplyHorizontalMerge(row.GetRowIndex(), 0, 3);
}
var fileName = "testfile";
doc.SaveToFile(fileName + ".docx");
SP.Document document = new SP.Document();
document.LoadFromFile(fileName + ".docx");
document.SaveToFile(fileName + ".pdf");
Attaching my template and the word and pdf files. Appreciate your help.
Thanks,
Santhoshi.