iText XMLWorker table weirdness when converting to PDF
<p>Ok, basically I've been trying to convert an HTML file to PDF using iText's XMLWorker in Java. Because there were issues converting directly from HTML, I've been using JTidy to convert the file to XHTML first (works like a charm), but when I try and convert it to PDF it messes up my layout big time.<br>
Again, both the HTML and XHTML files (which are identical when viewed in a browser) look exactly the way I want them to, but the PDF file is screwed.
Here's the HTML code, obviously I replaced all the information contained in the tables with "Bla":</p>

<pre><code>&lt;!DOCTYPE html&gt;&lt;html lang="en"&gt;
&lt;head&gt;&lt;meta charset="UTF-8"&gt;&lt;title&gt;Bla&lt;/title&gt;
&lt;style&gt;
    table#t0a {margin-top: 0.8cm; width: 90%; font-size: 13px; border-collapse: collapse;}
    table#t0a td {padding: 4px; border: 1px solid;}
    table#t0a td.span {width: 70%;}
    table#t0a td.long {width: 32%;}
    table#t0a td.short {width: 6%;}
    table#t0b {margin-top: 0.8cm; margin-bottom: 0.8cm; width: 90%; font-size: 13px; table-layout: fixed; border-collapse: collapse;}
    table#t0b td {padding: 4px; border: 1px solid; width: 20%;}
    table#t0b th {background-color: #bbb; padding: 4px; border: 1px solid;}
    table#t0b th:nth-child(2) {background-color: #bbb; padding: 4px; border: 1px solid; width: 20%;}
    table#t1a {margin-top: 0.8cm; width: 90%; font-size: 13px; border-collapse: collapse;}
    table#t1a td {padding: 4px; border: 1px solid;}
    table#t1a td.span {width: 70%;}
    table#t1a td.long {width: 32%;}
    table#t1a td.short {width: 6%;}
    table#t1b {margin-top: 0.8cm; margin-bottom: 0.8cm; width: 90%; font-size: 13px; table-layout: fixed; border-collapse: collapse;}
    table#t1b td {padding: 4px; border: 1px solid; width: 20%;}
    table#t1b th {background-color: #bbb; padding: 4px; border: 1px solid;}
    table#t1b th:nth-child(2) {background-color: #bbb; padding: 4px; border: 1px solid; width: 20%;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="container"&gt;
    &lt;div class="tables0" style="margin-left: 0.93cm"&gt;
&lt;table id="t0a" cellspacing="0"&gt;
    &lt;tr&gt;&lt;td&gt;Bla&lt;/td&gt;&lt;td class="span" colspan="3"&gt;Bla&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Bla&lt;/td&gt;&lt;td class="span" colspan="3"&gt;Bla&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Bla&lt;/td&gt;&lt;td class="long"&gt;Bla&lt;/td&gt;&lt;td class="short"&gt;Bla&lt;/td&gt;&lt;td class="long"&gt;Bla&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;table id="t0b" cellspacing="0"&gt;
    &lt;tr&gt;&lt;th&gt;&lt;b&gt;Bla&lt;/b&gt;&lt;/th&gt;&lt;th&gt;Bla&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;p&gt;Bla&lt;/p&gt;&lt;/td&gt;&lt;td&gt;Bla&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;th&gt;&lt;b&gt;Bla&lt;/b&gt;&lt;/th&gt;&lt;th&gt;Bla&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;p&gt;Bla&lt;/p&gt;&lt;/td&gt;&lt;td&gt;Bla&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;th&gt;&lt;b&gt;Bla&lt;/b&gt;&lt;/th&gt;&lt;th&gt;Bla&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;
            &lt;b&gt;Bla&lt;/b&gt;&lt;br&gt;Bla&lt;br&gt;
            &lt;b&gt;Bla&lt;/b&gt;&lt;br&gt;Bla&lt;br&gt;
            &lt;b&gt;Bla&lt;/b&gt;&lt;br&gt;Bla&lt;br&gt;
    &lt;/td&gt;&lt;td&gt;Bla&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;hr style="height:3px;border:none;color:#000;background-color:#000;" /&gt;
    &lt;div class="tables1" style="margin-left: 0.93cm"&gt;
&lt;table id="t1a" cellspacing="0"&gt;
    &lt;tr&gt;&lt;td&gt;Bla&lt;/td&gt;&lt;td class="span" colspan="3"&gt;Bla&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Bla&lt;/td&gt;&lt;td class="span" colspan="3"&gt;Bla&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Bla&lt;/td&gt;&lt;td class="long"&gt;Bla&lt;/td&gt;&lt;td class="short"&gt;Bla&lt;/td&gt;&lt;td class="long"&gt;Bla&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;table id="t1b" cellspacing="0"&gt;
    &lt;tr&gt;&lt;th&gt;&lt;b&gt;Bla&lt;/b&gt;&lt;/th&gt;&lt;th&gt;Bla&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;p&gt;Bla&lt;/p&gt;&lt;/td&gt;&lt;td&gt;Bla&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;th&gt;&lt;b&gt;Bla&lt;/b&gt;&lt;/th&gt;&lt;th&gt;Bla&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;p&gt;Bla&lt;/p&gt;&lt;/td&gt;&lt;td&gt;Bla&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;th&gt;&lt;b&gt;Bla&lt;/b&gt;&lt;/th&gt;&lt;th&gt;Bla&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;
            &lt;b&gt;Bla&lt;/b&gt;&lt;br&gt;Bla&lt;br&gt;
            &lt;b&gt;Bla&lt;/b&gt;&lt;br&gt;Bla&lt;br&gt;
            &lt;b&gt;Bla&lt;/b&gt;&lt;br&gt;Bla&lt;br&gt;
    &lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;&lt;/html&gt;
</code></pre>

<p>Now when viewed in the converted PDF, the first table extends through the edge of the screen to the right, which is obviously not intentional. Any ideas why this might be happening? </p>