Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show horizontal line in iTextSharp

I am creating a pdf and need to put a horizontal line in the page. Can anyone tell how to do that?

I have a xml file which has my html tag(<table>....</table>). And the whole content of xml file is parsed to a string which is used to create the pdf. Now some tags are not supported. One of them is <hr>. So is there any other tag which I can use in the xml file so that this will draw a line when the pdf is created using xml data.

Below is an example of xml xontent

<table>
   <tr>
     <td>
       <span>
           This is working properly.
       </span>
     </td>
   <tr>
</table>

<table>
   <tr>
     <td>
       <span>
           <hr>
           This is not working properly.
       </span>
     </td>
   <tr>
</table>

Please let me know if any more information is needed.

Thanks in advance.

like image 777
Narendra Avatar asked Mar 11 '13 09:03

Narendra


People also ask

How to add horizontal line in itextsharp?

If you have a PdfContentByte object cb , you can draw a line like this: cb. MoveTo(x1, y1); cb. LineTo(x2, y2); cb.


1 Answers

The following creates a full width black line a few pixels thick, I'm using HTMLWorker.Parse:

<table>
   <tr>
    <td>
       <span>
           This is working properly.
       </span>
    </td>
   <tr>
</table>

<table>
   <tr>
    <td>
       <span>
       <table border="1" cellpadding="0" cellspacing="0"><tr><td>&nbsp;</td></tr></table>

           This is working properly now too!
       </span>
    </td>
   <tr>
</table>
like image 150
Peter Avatar answered Oct 05 '22 07:10

Peter