Free Support Forum - aspose.com

Determining a location for a shape in a document

Good morning,

I'm currently working on dynamically creating a document. Part way through, I'd like to add a horizontal line, but I do not know which coordiantes to use. Is there any way to determine the location I should use to add the line based upon the text I have already added to the document?

Thanks,

Matt

Hi

Thanks for your inquiry. I think that you can try using the following code.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.Writeln("some text before horizontal line");

Shape line = new Shape(doc, ShapeType.Line);

line.Width = 500;

line.Height = 0;

builder.CurrentParagraph.AppendChild(line);

builder.Writeln("some text after horizontal line");

doc.Save(@"427_106820_Sonreir\out.doc");

Also you can try this.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.Writeln("some text before horizontal line");

builder.InsertHtml("");

builder.Writeln("some text after horizontal line");

doc.Save(@"427_106820_Sonreir\out.doc");

I hope that this will help you.

Best regards.