Free Support Forum - aspose.com

Add horizontal line after some text

Hi,

I’d like to add horizontal line after text, i.e:

some text some text some text some text

some other text some text some text some text some text

some text some text some text some text

some other text some text some text some text some text


Is it possible to do it without HTML?

Thanks,
Marcin

Hi Marcin,


Thanks for contacting support.

In order to add horizontal line, please try using Graph object. Please try using the following code snippet to accomplish your requirement. For your reference, I have also attached the resultant PDF document which is generated over my end.

You may consider visiting the following link for further information on Working with Graphs (Generator)

[C#]

Pdf pdf1 = new Pdf();<o:p></o:p>

Section sec1 = pdf1.Sections.Add();

// create text paragraph

Aspose.Pdf.Generator.Text text1 = new Text("some text some text some text some text ");

// add text to paragraphs collection of section

sec1.Paragraphs.Add(text1);

Graph graph1 = new Graph(sec1, 200,5);

sec1.Paragraphs.Add(graph1);

float[] posArr = new float[] { 1, 0, 300, 0 };

Line l1 = new Line(graph1, posArr);

l1.GraphInfo.Color = new Aspose.Pdf.Generator.Color("Red");

graph1.Shapes.Add(l1);

pdf1.Save("c:/pdftest/Line_Text_Paragraphs.pdf");

Thanks, worked great!