New run in empty paragraph formatting


i have an empty paragraph inside a table cell with ParagraphBreakFont matching the formatting of the cell when i open the document in Word. Paragraph.ParagraphFormat matches some font settings outside of the table.

I need to add a new run to this paragraph with the new runs Run.Font property matching ParagraphBreakFont. Is there a way to have the new run automatically take the font from ParagraphBreakFont of surrounding paragraph without having to set the properties manually?

When i just add a plain Run to the empty paragraph the new runs formatting always matches the Paraph.ParagraphFormat.Style.Font, which is not consistent as it doesn’t match the behaviour i have in word when i type into an empty cell.

I’m using aspose.words .net version

Kind regards,

Hi Torsten,

Thanks for your inquiry. In your case, we suggest you please move the cursor to the end of paragraph and insert text using DocumentBuilder.Write method.

Following code example shows how to insert the text (add new Run node) with same font formatting as of the paragraph break character. Hope this helps you.

Document doc = new Document(MyDir + "in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
Table table = (Table)doc.GetChild(NodeType.Table, 0, true);
Paragraph para = table.FirstRow.FirstCell.LastParagraph;
// Move the cursor to the end of paragraph
builder.MoveToParagraph(doc.GetChildNodes(NodeType.Paragraph, true).IndexOf(para), -1);
// DocumentBuilder.Write will create a new run
builder.Write("New Text");
doc.Save(MyDir + "Out.docx");

looks good, thx a lot

Hi Torsten,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.