Free Support Forum - aspose.com

How to move cursor to (x- y) and create a text box there?

How to move cursor to (x, y) and create a text box there?

The x, y are in inch or cm.

Thanks in advance!

Hi David,


Thanks for your inquiry. I believe, you can achieve what you’re looking for after using the following code snippet:

Document doc = new
Document();

Shape textBox = new Shape(doc, ShapeType.TextBox);

textBox.WrapType = WrapType.None;

textBox.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;

textBox.RelativeVerticalPosition = RelativeVerticalPosition.Page;

textBox.Height = 50;

textBox.Width = 200;

textBox.Top = ConvertUtil.InchToPoint(1);

textBox.Left = ConvertUtil.InchToPoint(5.5);

textBox.AppendChild(new Paragraph(doc));

Paragraph para = textBox.FirstParagraph;

para.ParagraphFormat.Alignment = ParagraphAlignment.Center;

Run run = new Run(doc);

run.Text = "Content in textbox";

para.AppendChild(run);

doc.FirstSection.Body.FirstParagraph.AppendChild(textBox);

doc.Save(@“C:\Temp\out.doc”);


I hope, this helps.

Best regards,