本文介绍了得到这个“org.xhtmlrenderer.render.BlockBox”无法强制转换为org.xhtmlrenderer.newtable.TableBox"在尝试渲染pdf时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试渲染pdf时遇到此错误。我正在使用Nicolas Leroux的PDF模块作为播放框架。

I am getting this error while I am trying to render a pdf. I am using Nicolas Leroux's PDF module for the play framework.

这是整个stackstrace:。谷歌搜索只显示4个结果。他们建议删除任何浮动属性和位置属性,我已经删除了,jsut尝试一下。我仍然面临这个问题。有没有人能够解决这个问题?

This is the entire stackstrace: Pastebin. Googling only reveals 4 results. They suggest removing any float properties, and position attributes, which I have removed, jsut to give it a try. I am still facing this problem. Has anyone been able to solve the issue?

编辑:这是呈现pdf的html:

This is the html that renders the pdf:

#{extends 'main.html' /} #{set title:'Salary Details' /}
<html>
<head>
<title>Employee Name</title>
<style>
body {
    font: 9pt Arial, Helvetica, sans-serif;
}

.container {
    margin: 0 auto;
    width: 1000px;
    border: 1px solid black;
    padding: 12px;
}

.logoClass {
    width: 200px;
    height: 85px;;
}

.companyAddressClass {
    width: 60%;
    margin: 0 auto;
    font-size: 17px;
    font-weight: bold;
    text-align: center;
}

.empClass table {
    width: 100%;
    border: 1px solid #ccc;
    border-collapse: collapse;
    margin: 10px 0px;
}

.empClass table th,td {
    border: 1px solid #ccc;
    padding: 5px 5px;
}

.empClass table th {
    background: #f2f2f2;
}
</style>
</head>

<body onload="window.print();">

    %{for(int i=0;i<dataList.size ();i=i+1){}%
    <div class="container" style="page-break-after:#{if i == dataList.size()-1} avoid;#{/if} #{else} always; #{/else}">
    <div class="logoClass"></div>
    <div class="companyAddressClass">
        ${dataList.get(i).distributorName},<br /> ${dataList.get(i).city},<br />
        ${dataList.get(i).state} <br /> <br /> <span>Payslip for the
            month of ${dataList.get(i).salaryMonth}</span>
    </div>
    <br class="clear" />
    <div class="empClass">
        <table border="1">
            <tr>
                <td>Employee No: ${dataList.get(i).employeeNumber}</td>
                <td>Location: ${dataList.get(i).location}</td>
            </tr>
            <tr>
                <td>Name: ${dataList.get(i).employeeName}</td>
                <td>Salary for the M/O: ${dataList.get(i).salaryMonth}</td>
            </tr>
            <tr>
                <td>Bank Name: ${dataList.get(i).bankName}</td>
                <td>Designation: ${dataList.get(i).designation}</td>
            </tr>
            <tr>
                <td>Bank Acc No: ${dataList.get(i).accountNumber}</td>
                <td>Join Date: ${dataList.get(i).joinDate}</td>
            </tr>
            <tr>
                <td>PF No: ${dataList.get(i).pfNumber}</td>
                <td>Gender: ${dataList.get(i).gender}</td>
            </tr>
            <tr>
                <td>ESI No: ${dataList.get(i).esiNumber}</td>
                <td>LOP: ${dataList.get(i).lop}</td>
            </tr>
            <tr>
                <td>PAN No: ${dataList.get(i).panNumber}</td>
                <td>Days Worked: ${dataList.get(i).daysWorked}</td>
            </tr>
        </table>
    </div>
    <br />
    <div class="empClass">
        <table border="1">
            <tr>
                <th colspan="3">Earnings</th>
                <th colspan="2">Deductions</th>
            </tr>
            <tr>
                <th align="left">Header</th>
                <th align="right">Actual</th>
                <th align="right">Paid</th>
                <th align="left">Header</th>
                <th align="right">Paid</th>
            </tr>
            <tr>
                <td>Basic</td>
                <td align="right">${dataList.get(i).basic}</td>
                <td align="right">${dataList.get(i).basic}</td>
                <td>PF</td>
                <td align="right">${dataList.get(i).pf}</td>
            </tr>
            <tr>
                <td>HRA</td>
                <td align="right">${dataList.get(i).hra}</td>
                <td align="right">${dataList.get(i).hra}</td>
                <td>ESICEE</td>
                <td align="right">${dataList.get(i).esicee}</td>
            </tr>
            <tr>
                <td>Conveyance Allowance</td>
                <td align="right">${dataList.get(i).conveynanceAllowance}</td>
                <td align="right">${dataList.get(i).conveynanceAllowance}</td>
                <td>ESICEE(PWS)</td>
                <td align="right">${dataList.get(i).esiceePWS}</td>
            </tr>
            <tr>
            <td>Medical Allowance</td>
                <td align="right">${dataList.get(i).medicalAllowances}</td>
                <td align="right">${dataList.get(i).medicalAllowances}</td>
                <td>PT</td>
                <td align="right">${dataList.get(i).pt}</td>
            </tr>
            <tr>
                <td>Special Allowance</td>
                <td align="right">${dataList.get(i).specialAllowance}</td>
                <td align="right">${dataList.get(i).specialAllowance}</td>
                <td>PT(PWS)</td>
                <td align="right">${dataList.get(i).ptPWS}</td>
            </tr>
            <tr>
                <td>Incentives</td>
                <td align="right">${dataList.get(i).midMonthAmountPWS}</td>
                <td align="right">${dataList.get(i).midMonthAmountPWS}</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td>Other Allowances</td>
                <td align="right">${dataList.get(i).otherAllowance}</td>
                <td align="right">${dataList.get(i).otherAllowance}</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td colspan="3" align="right">Total
                    Earnings:${dataList.get(i).totalEarnings}</td>
                <td colspan="2" align="right">Total Deduction
                    :${dataList.get(i).totalDeduction}</td>
            </tr>
            <tr>
                <td colspan="3">&nbsp;</td>
                <td colspan="2" align="right"><strong>Salary Credited
                        : ${dataList.get(i).salaryCredited}</strong></td>
            </tr>
        </table>

        <table>
        <thead>
            <tr>
                <th>Position Title</th>
                <th>City Name</th>
                <th>State Name</th>
            </tr>
        </thead>
        <thead>
            <tr>
                ..
                ..
                ..
                ..
                <th>${dataList.get(i).positionTitle}</th>
                <th>${dataList.get(i).cityName}</th>
                <th>${dataList.get(i).stateName}</th>
            </tr>
        </thead>
    </table>
    <br>
        <table>
        <thead>
            <tr>
                <th>Some Header</th>
                <th>Some Header</th>
                <th>Some Header</th>
                <th>Some Header</th>

            </tr>
        </thead>
        <tbody>
            <tr>
                <td align="center">Values</td>
                ..
                ..
                ..
                ..
                ..
            </tr>
        </tbody>
    </table>
    </div>
    <div>
        <span style="font-size: 15px; font-weight: bold;"> Salary
            Credited Amount(In Words): ${dataList.get(i).salaryCreditedInWord} </span>
    </div>
    </div>
    <br />
    <br />

    %{}}% 
</body>
</html>

我使用Windows 7和Tomcat6作为测试环境,与人们相同的环境正面临麻烦。

I am using Windows 7 and Tomcat6 as the testing environment, the same environment that people over here are facing trouble with.

谢谢。

推荐答案

是对您的问题的修复。你可以并将其放在源代码中,这样就不必重建库jar。

This commit is a fix for your problem. You can download the whole class and put it in your source code, so you haven't to rebuild the library jar.

这篇关于得到这个“org.xhtmlrenderer.render.BlockBox”无法强制转换为org.xhtmlrenderer.newtable.TableBox&quot;在尝试渲染pdf时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 08:16