Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

problem in drawing a line in a pdf file using itextsharp

I am generating a pdf file in asp.net c# using itextsharp. i am not able to draw a horizontal line/verticle line/dotted line.

i tried to draw a line using the following code,i am getting no errors but the line is also not getting displayed in the pdf file

    PdfContentByte cb = wri.DirectContent;
    cb.SetLineWidth(2.0f);   // Make a bit thicker than 1.0 default
    cb.MoveTo(20, pdfDocument.Top - 40f);
    cb.LineTo(400, pdfDocument.Top - 40f);
    cb.Stroke();

What is the problem in the code.Is it because of the position of x y co-ordinates? I had used rough points to know approximate position in pdf,but the line never apears in the pdf file.

The output i am looking out for is as shown in image below.enter image description here

like image 309
Ishan Avatar asked Feb 24 '11 10:02

Ishan


1 Answers

Paragraph p = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, BaseColor.BLACK, Element.ALIGN_LEFT, 1)));
document.Add(p);
like image 110
ettore ct Avatar answered Oct 23 '22 11:10

ettore ct