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

Free Support Forum - aspose.com

Unable to add a text outside control

Hello,

I have a word document with DateTimePicker control in it. When I try to add a text to this document, the text appears INSIDE the control. I am using this code:
var doc1 = new Document(@“C:\Date_Picker_only.docx”);
var builder1 = new Aspose.Words.DocumentBuilder(doc1);
builder1.Writeln(“wrinting test line”);
builder.MoveToDocumentEnd();
builder1.Write(“Another line”);
doc1.Save(@“C:\Test.docx”);
Is there a way to add text which will be OUTSIDE the control?
Thank you,
Alexei

Hi Alexei,


Thanks for your inquiry. You can achieve this by executing the following code:

Document doc = new
Document(MyDir + @“Date_Picker_only.docx”);

DocumentBuilder builder = new DocumentBuilder(doc);

Node lastNode = doc.LastSection.Body.LastChild;

lastNode.ParentNode.InsertAfter(new Paragraph(doc), lastNode);

builder.MoveTo(doc.LastSection.Body.LastParagraph);

builder.Write("Some text");

doc.Save(MyDir + @“out.docx”);


I hope, this helps.

Best regards,

It works!

Thank you