Search code examples
cssitextxmlworker

XMLWorker: cell's vertical-align not working


If you check this code:

<table>
    <tr>
        <td border="1">
            <table>
                <tr><td>Blah</td></tr>
                <tr><td>Blah</td></tr>
                <tr><td>Blah</td></tr>
            </table>
        </td>
        <td border="1">
            <table>
                <tr><td>Blah</td></tr>
                <tr><td>Blah</td></tr>
            </table>
        </td>
    </tr>
</table>

In here:
http://demo.itextsupport.com/xmlworker/

You will see this: vertical aligned to top

But if you click on "transform" so that XMLWorker creates the PDF, this is the result:

Not in top when converted to PDF

So... is vertical align broken? how can I move that second table to the top of the parent's cell?


Solution

  • You forgot to define the vertical alignment of the right cell.

    I have adapted your HTML (table4_css.html):

    <table>
        <tr>
            <td>
                <table border="1">
                    <tr><td>Blah</td></tr>
                    <tr><td>Blah</td></tr>
                    <tr><td>Blah</td></tr>
                </table>
            </td>
            <td valign="top">
                <table border="1">
                    <tr><td>Blah</td></tr>
                    <tr><td>Blah</td></tr>
                </table>
            </td>
        </tr>
    </table>
    

    You can find the source code to convert this HTML to PDF here. Take a look at the resulting PDF: html_table_7.pdf

    enter image description here

    As you can see, introducing the valign attribute moved the right part up.