Drawing with the iTextSharp PdfContentByte class can be a bit confusing. The height is actually relative to the bottom, not the top. So the top of the page is not 0f, but actually document.Top , which is 726f in size of your PageSize.LETTER page. Therefore, if you want to draw your line 30 units on top, try:
cb.MoveTo(20, document.Top - 30f); cb.LineTo(400, document.Top - 30f);
Just curious - why is it difficult and not using table borders? (I noticed that you set your borders to 0). Trying to draw lines by hand is the biggest pain. If you ever move content in your PDF, you will need to make sure your measurements are still working.
Try the following:
numeroCell.Border = 0; numeroCell.BorderColorBottom = new BaseColor(System.Drawing.Color.Black); numeroCell.BorderWidthBottom = 1f; codigoCell.Border = 0; codigoCell.BorderColorBottom = new BaseColor(System.Drawing.Color.Black); codigoCell.BorderWidthBottom = 1f; nombreCell.Border = 0; nombreCell.BorderColorBottom = new BaseColor(System.Drawing.Color.Black); nombreCell.BorderWidthBottom = 1f;
This should give you a nice solid black line under the heading, without any measurements:

Pandincus
source share