iText XMLWorker CSSResolver 在 Java 7 到 Java 8 上产生不同的结果

iText XMLWorker CSSResolver produces different results on Java 7 to Java 8

我的网站有一项功能,允许人们粘贴 html 评论,然后将这些评论输出为 pdf 报告。 我有一个问题,从 Java 7 升级到 Java 8(没有其他代码更改)后,iText XMLWorker 和 CSSResolver 似乎输出 pdf 中的 html 表格,边框非常粗.

Java 7:

Java 8:

有人知道为什么会这样吗? 是否有新的 settings/libraries for iText for Java 8 我错过了?

这是 iTextPdf 的错误吗?

编辑

Maven 依赖项:

    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>itextpdf</artifactId>
        <version>5.5.6</version>
    </dependency>
    <dependency>
        <groupId>com.itextpdf.tool</groupId>
        <artifactId>xmlworker</artifactId>
        <version>5.5.6</version>
    </dependency>
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>itext-asian</artifactId>
        <version>5.2.0</version>
    </dependency>

用于处理用户粘贴评论的代码:

            String commentText = itemComment.getComment();

            // CSS
            CSSResolver cssResolver = new StyleAttrCSSResolver();

            // HTML
            HtmlPipelineContext htmlContext = new HtmlPipelineContext( null );
            htmlContext.setTagFactory( Tags.getHtmlTagProcessorFactory() );

            // Pipelines
            ElementList elements = new ElementList();
            ElementHandlerPipeline pdf = new ElementHandlerPipeline( elements, null );
            HtmlPipeline html = new HtmlPipeline( htmlContext, pdf );
            CssResolverPipeline css = new CssResolverPipeline(cssResolver, html);

            // XML Worker
            XMLWorker worker = new XMLWorker( css, true );
            XMLParser p = new XMLParser( worker );
            p.parse( new ByteArrayInputStream( commentText.getBytes() ) );


            String commentDate = sdf.format( itemComment.getCommentDate() );
            String commentAuthor = itemComment.getAuthor().getFirstname() + " " + itemComment.getAuthor().getSurname();
            dataTable.addCell(new Phrase(commentDate, labelFont));
            dataTable.addCell(new Phrase(commentAuthor, labelFont));

            PdfPCell commentCell = new PdfPCell();
            commentCell.setColspan( 2 );
            Phrase commentPhrase = new Phrase();
            commentPhrase.setFont( dataFont );
            if( !elements.isEmpty() )
            {
                for( Element element : elements )
                {
                    commentCell.addElement( element );
                }
            }
            else
            {
                commentPhrase.add( commentText );
                commentCell.addElement( commentPhrase );
            }
            dataTable.addCell(commentCell);

示例 html(这些用户从 Excel 复制并粘贴表格)

<table style="width: 458pt; border-collapse: collapse;" border="0" cellSpacing="0" cellPadding="0" width="609">

    <colgroup><col style="width: 190pt; mso-width-source: userset; mso-width-alt: 9252;" width="253">
        </col><col style="width: 55pt; mso-width-source: userset; mso-width-alt: 2669;" span="2" width="73">
        </col><col style="width: 56pt; mso-width-source: userset; mso-width-alt: 2706;" width="74">
        </col><col style="width: 51pt; mso-width-source: userset; mso-width-alt: 2486;" span="2" width="68">
        </col></colgroup><tbody><tr style="height: 15pt; mso-height-source: userset;" height="20">
    <td style="border: 0px navy; width: 190pt; height: 15pt; " class="xl77" height="20" width="253"><strong><font color="#000080" size="2" face="Verdana">ABC12345
        - 1234567890123</font></strong></td>
    <td style="border: 0px navy; width: 55pt; " class="xl66" width="73"></td>
    <td style="border: 0px windowtext; width: 55pt; " class="xl67" width="73"></td>
    <td style="border: 0px windowtext; width: 56pt; " class="xl67" width="74"></td>
    <td style="border: 0px windowtext; width: 51pt; " class="xl68" width="68"></td>
    <td style="border: 0px windowtext; width: 51pt; " class="xl68" width="68"></td>
</tr>
<tr style="height: 15pt; mso-height-source: userset;" height="20">
    <td style="border: 0.5pt solid windowtext; height: 15pt; " class="xl69" height="20"><font color="#000080" size="2" face="Verdana">Transactional Charges</font></td>
    <td style="border-width: 0.5pt 0.5pt 0.5pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext navy; " class="xl70"><font color="#000080" size="2" face="Verdana">£</font></td>
    <td style="border-width: 0.5pt 0.5pt 0.5pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext navy; " class="xl70"><font color="#000080" size="2" face="Verdana">VAT</font></td>
    <td style="border-width: 0.5pt 0.5pt 0.5pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext navy; " class="xl70"><font color="#000080" size="2" face="Verdana">Total</font></td>
    <td style="border-width: 0.5pt 0.5pt 0.5pt 0px; border-style: solid solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0.5pt 0.5pt 0.5pt 0px; border-style: solid solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
</tr>
<tr style="height: 9pt; mso-height-source: userset;" height="12">
    <td style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: navy windowtext windowtext; width: 190pt; height: 9pt; " class="xl72" height="12" width="253"><font color="#000080" size="2" face="Verdana">Remove item (Labour only)</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl73"><font color="#000080" size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
</tr>
<tr style="height: 9pt; mso-height-source: userset;" height="12">
    <td style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: navy windowtext windowtext; width: 190pt; height: 9pt; " class="xl72" height="12" width="253"><font color="#000080" size="2" face="Verdana">Emergency Removal (Labour Only)</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl73"><font color="#000080" size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
</tr>
<tr style="height: 9pt; mso-height-source: userset;" height="12">
    <td style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: navy windowtext windowtext; width: 190pt; height: 9pt; " class="xl72" height="12" width="253"><font color="#000080" size="2" face="Verdana">Replace item (Labour only)</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl73"><font color="#000080" size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
</tr>
<tr style="height: 9pt; mso-height-source: userset;" height="12">
    <td style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: navy windowtext windowtext; height: 9pt; " class="xl69" height="12"><font color="#000080" size="2" face="Verdana">Additional
        Visits</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl73"><font color="#000080" size="2" face="Verdana">£80.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£16.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£96.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
</tr>
<tr style="height: 9pt; mso-height-source: userset;" height="12">
    <td style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: navy windowtext windowtext; height: 9pt; " class="xl69" height="12"><font color="#000080" size="2" face="Verdana">Part A123</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl73"><font color="#000080" size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
</tr>
<tr style="height: 9pt; mso-height-source: userset;" height="12">
    <td style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: navy windowtext windowtext; height: 9pt; " class="xl69" height="12"><font color="#000080" size="2" face="Verdana">Part B123</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl73"><font color="#000080" size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
</tr>
<tr style="height: 9pt; mso-height-source: userset;" height="12">
    <td style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: navy windowtext windowtext; height: 9pt; " class="xl69" height="12"><font color="#000080" size="2" face="Verdana">Part C123</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl73"><font color="#000080" size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
</tr>
<tr style="height: 9pt; mso-height-source: userset;" height="12">
    <td style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: navy windowtext windowtext; height: 9pt; " class="xl69" height="12"><font color="#000080" size="2" face="Verdana">Part D123</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl73"><font color="#000080" size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
</tr>
<tr style="height: 9pt; mso-height-source: userset;" height="12">
    <td style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: navy windowtext windowtext; height: 9pt; " class="xl69" height="12"><font color="#000080" size="2" face="Verdana">Security</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl73"><font color="#000080" size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
</tr>
<tr style="height: 9pt; mso-height-source: userset;" height="12">
    <td style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: navy windowtext windowtext; height: 9pt; " class="xl69" height="12"><font color="#000080" size="2" face="Verdana">Visit Requested</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl73"><font color="#000080" size="2" face="Verdana">£58.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£11.60</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£69.60</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
</tr>
<tr style="height: 9pt; mso-height-source: userset;" height="12">
    <td style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: navy windowtext windowtext; height: 9pt; " class="xl69" height="12"><font color="#000080" size="2" face="Verdana">Revisit</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl73"><font color="#000080" size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
</tr>
<tr style="height: 9pt; mso-height-source: userset;" height="12">
    <td style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: navy windowtext windowtext; height: 9pt; " class="xl69" height="12"><font color="#000080" size="2" face="Verdana">Admin</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl73"><font color="#000080" size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
</tr>
<tr style="height: 9pt; mso-height-source: userset;" height="12">
    <td style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: navy windowtext windowtext; height: 9pt; " class="xl69" height="12"><font color="#000080" size="2" face="Verdana">Category A
        Visit</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl73"><font color="#000080" size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
</tr>
<tr style="height: 9pt; mso-height-source: userset;" height="12">
    <td style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: navy windowtext windowtext; height: 9pt; " class="xl69" height="12"><font color="#000080" size="2" face="Verdana">Warrant</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl73"><font color="#000080" size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
</tr>
<tr style="height: 9pt; mso-height-source: userset;" height="12">
    <td style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: navy windowtext windowtext; height: 9pt; " class="xl69" height="12"><font color="#000080" size="2" face="Verdana">Change of Locks</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl73"><font color="#000080" size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
</tr>
<tr style="height: 9pt; mso-height-source: userset;" height="12">
    <td style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: navy windowtext windowtext; height: 9pt; " class="xl69" height="12"><font color="#000080" size="2" face="Verdana">Additional Time
        on Site</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl73"><font color="#000080" size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: navy windowtext windowtext navy; " class="xl74"><font color="#000080" size="2" face="Verdana">£0.00</font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
</tr>

<tr style="height: 9pt; mso-height-source: userset;" height="12">
    <td style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: red windowtext windowtext; height: 9pt; " class="xl75" height="12"><strong><font color="#ff0000" size="2" face="Verdana">Total</font></strong></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: red windowtext windowtext red; " class="xl76"><strong><font color="#ff0000" size="2" face="Verdana">£138.00</font></strong></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: red windowtext windowtext red; " class="xl76"><strong><font color="#ff0000" size="2" face="Verdana">£27.60</font></strong></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: red windowtext windowtext red; " class="xl76"><strong><font color="#ff0000" size="2" face="Verdana">£165.60</font></strong></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
</tr>
<tr style="height: 9pt; mso-height-source: userset;" height="12">
    <td style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: windowtext; height: 9pt; " class="xl71" height="12"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
    <td style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: windowtext; " class="xl71"><font size="2" face="Verdana"> </font></td>
</tr>

</tbody></table>

如我对问题的评论所述,我们遇到了一个奇怪的情况。

|Java    | iText 5.5.6 | iText 5.5.7
|7       | good        | bad
|8       | bad         | bad

经过一番调查后发现,iText 5.5.6 中的不一致是我们使用 HashMap 造成的。在Java7中,迭代器经历了某个HashMap如下:先是border-left-style,然后是border-left-width;在 Java 8 中,它是相反的。由于我们在 com.itextpdf.tool.xml.css.apply.HtmlCellCssApplier::setLeftOfBorder 中的代码取决于迭代顺序,因此我们的实现很容易受到此更改的影响。

HashMap 迭代的行为在 Java 8 中发生了变化,如您在 http://examples.javacodegeeks.com/core-java/util/hashmap/hashmap-changes-in-java-8/ 中所见。

我们意识到了这一点,并在 iText 5.5.7 中进行了修复,将 HashMap 替换为 LinkedHashMap,因为后者保证了对条目集的 'historic' 迭代。参见 https://github.com/itext/xmlworker/commit/92b2146bcb37b283863e24e5cb18ed661411387c。显然,这不是完全正确的举动,因为 Java 7 和 8 现在都得到了错误的顺序。我会将其添加到开发积压中,我们将尝试解决此问题。

编辑 1:

以下是我们正在尝试修复的最小用例。它目前在其中一个单元格周围生成一个矩形,这当然不应该发生。

<table>
  <tr>
    <td style="border-style: none; border-width: 0px;">a</td>
    <td style="border-width: 0px; border-style: none;">a</td>
  </tr>
</table>

EDIT2:此修复自 11 月 27 日发布的 iText 5.5.8 起可用