Getting this “org.xhtmlrenderer.render.BlockBox cannot be cast to org.xhtmlrenderer.newtable.TableBox” while trying to render a pdf

六眼飞鱼酱① 提交于 2019-12-23 03:12:58

问题


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.

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?

EDIT: 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>

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

Thanks.


回答1:


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.



来源:https://stackoverflow.com/questions/13137401/getting-this-org-xhtmlrenderer-render-blockbox-cannot-be-cast-to-org-xhtmlrende

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!