Center align using html2pdf with lines on both side

15.2k Views Asked by At
<table style="width: 100%;">
        <tr>
            <td style="text-align: center;width=100%;"><h4>Education</h4></td>
        </tr>
</table>

This is the code I am using. Now i want o/p like this:

enter image description here

How can I draw these horizontal lines?

2

There are 2 best solutions below

0
On BEST ANSWER
<table style="width: 100%; padding-top:-10px;">
            <tr>
        <td style="text-align: center;width=33%;"><hr style="height: .3mm; background: #000; "></td>
        <td style="text-align: center;width=33%; padding-top:-5px;">
<h4>Education</h4>
</td>
<td style="text-align: center;width=33%;"><hr style="height: .3mm; background: #000; ">     </td>
</tr>
</table>

This solved my problem.

2
On

If I paste http://fiddle.jshell.net/4QskF/show/light/ into the "enter a URL of your choice" box on the html2pdf homepage, I get output in the PDF which looks like your picture.

I used this HTML/CSS:

<div style="border-bottom: 1px solid #000"></div>
<h4 style="width:200px; margin:-10px auto 0 auto; text-align:center; background:#fff">Education</h4>

It might need some tweaks so you can actually use it in your document, but I think the idea works.