Nachti
1
Hi,
if I use following code i get to the end of the textbox and not to the end of the appended document to write some text:
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToDocumentEnd();
Aspose.Words.Font font = builder.Font;
font.Size = 16;
builder.Write("Sample text.");
How can I move to the ‘real’ end of the document in this case ?
How can I found at that I am at the false node and move back ?
Kind regards,
Guido
Hi Guido,
Thanks for your inquiry. I think, you can use the following code to achieve what you’re looking for:
Document doc = new Document(MyDir + @"movetoend.docx");
Paragraph lastPara = doc.LastSection.Body.LastParagraph;
Paragraph newPara = new Paragraph(doc);
newPara.Runs.Add(new Run(doc, "Sample text"));
lastPara.ParentNode.InsertAfter(newPara, lastPara);
doc.Save(MyDir + @"out.docx");
I hope, this helps.
Best regards,
Nachti
3
Hi Awais,
but how can I do it with Document Builder ?
Additionally the document is unknown to me.
That means I have to open the document, move to end of the document and write something.
Kind regards,
Guido
Hi Guido,
Thanks for your inquiry. In this case, you need to insert a new Paragraph after the last Paragraph in the Document. I would suggest you please read about the DOM structure of Aspose.Words Document and how to insert nodes at specific positions in the following articles:
https://docs.aspose.com/words/net/aspose-words-document-object-model/
https://docs.aspose.com/words/net/navigation-with-cursor/
Best regards,