We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

MoveToDocumentEnd move to textbox end

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,

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:
http://www.aspose.com/docs/display/wordsnet/Document+Tree+Navigation
http://www.aspose.com/docs/display/wordsnet/Moving+the+Cursor

Best regards,