How to insert text at the top right corner of word document

I need to insert table or couple of lines of text at the top right corner of a word document. how can I do this? using c# aspose word.

Hi there,

Thanks for your inquiry. In your case, we suggest you please insert the text box (Shape node) in the document and set its position as shown below. Insert the table and other contents inside the shape. Hope this helps you.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = new Shape(doc, ShapeType.TextBox);
shape.Width = 200;
shape.Height = 100;
doc.FirstSection.Body.FirstParagraph.AppendChild(shape);
shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Margin;
shape.HorizontalAlignment = HorizontalAlignment.Right;
shape.RelativeVerticalPosition = RelativeVerticalPosition.Margin;
shape.VerticalAlignment = VerticalAlignment.Top;
shape.AppendChild(new Paragraph(doc));
builder.MoveTo(shape.FirstParagraph);
Table table = builder.StartTable();
// Insert a cell
builder.InsertCell();
builder.Write("This is row 1 cell 1");
// Insert a cell
builder.InsertCell();
builder.Write("This is row 1 cell 2");
builder.EndRow();
// Insert a cell
builder.InsertCell();
builder.Writeln("This is row 2 cell 1");
// Insert a cell
builder.InsertCell();
builder.Writeln("This is row 2 cell 2");
builder.EndRow();
builder.EndTable();
doc.Save(MyDir + "Out.docx");

If you still face problem, please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate as to how you want your final Word output be generated like. We will then provide you more information on this along with code.