1 year ago

#334037

test-img

Roy Li

MPDF unexpected bold text

Here is a code snippet I used to generate PDF when I used mPDF, version of the mPDF is v8.0.

Updated: 30/03/2022, added the settings of mPDF and the stylesheet I used. Found out the "overflow:hidden" in CSS settings triggered the problem.

But a question is, if I do not set the "overflow:hidden" on tables and sometimes when the text inside of the table is pretty long, and font-size will become smaller to make the table fit in a page.


$config = [
    'mode' => 'c',
    'format' => "A4",
    'default_font' => 'arial',
    'orientation' => "P",
];


$htmlContent = '<html>
<head>
    <style>
    @page {
      margin-left: 12.7mm;
      margin-right: 12.7mm;
      margin-top: 20mm;
      margin-bottom: 20mm;
      margin-header: 5mm;
      margin-footer: 5mm; /* <any of the usual CSS values for margins> */
      marks: none;
    }

    table{
      width:100%;
      overflow:hidden;
    }
    </style>
</head>
<body>
    <div class="page_holder">
        <p>25/03/2022</p>
        <p>Dear Dr Jayden,</p>
        <p>Thank you for agreeing to undertake respirable crystalline silica health monitoring for the following worker.</p>
        <table class="wp-block-advgb-table advgb-table-frontend is-style-padding ">
            <tbody>
            <tr>
                <td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
                    data-border-color="#ffffff">Jayden
                </td>
            </tr>
            <tr>
                <td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
                    data-border-color="#ffffff"><strong>Date of Birth</strong></td>
                <td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
                    data-border-color="#ffffff">31/12/1989
                </td>
            </tr>
            <tr>
                <td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
                    data-border-color="#ffffff"><strong>Description of tasks this worker will complete with engineered stone
                        fabrication</strong></td>
                <td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
                    data-border-color="#ffffff">Final Task
                </td>
            </tr>
            <tr>
                <td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
                    data-border-color="#ffffff"><strong>History working with engineered stone</strong></td>
                <td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
                    data-border-color="#ffffff">History
                </td>
            </tr>
            </tbody>
        </table>


        <p><strong>If yes, please list previous work history with engineered stone:</strong></p>

        <table class="wp-block-advgb-table advgb-table-frontend is-style-padding " style="table-layout: fixed">
            <tbody>
            <tr>
                <td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
                    data-border-color="#ffffff">Workers Name</td>
                <td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
                    data-border-color="#ffffff">Jayden
                </td>
            </tr>
            <tr>
                <td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
                    data-border-color="#ffffff">Date of Birth</td>
                <td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
                    data-border-color="#ffffff">31/12/1989
                </td>
            </tr>
            <tr>
                <td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
                    data-border-color="#ffffff">Description of tasks this worker will complete with engineered stone
                    fabrication</td>
                <td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
                    data-border-color="#ffffff">Final Task
                </td>
            </tr>
            <tr>
                <td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
                    data-border-color="#ffffff"><strong>History working with engineered stone</strong></td>
                <td style="background-color:#f4f4f4;border-width:2px;border-top-color:#ffffff;border-right-color:#ffffff;border-bottom-color:#ffffff;border-left-color:#ffffff"
                    data-border-color="#ffffff">History
                </td>
            </tr>
            </tbody>
        </table>


        <p>I confirm that the minimum health monitoring required has been identified in the attached document; WHSQ Health
            monitoring standard - crystalline silica. Upon completion of the health monitoring could you please provide a report
            for this worker that at a minimum contains the information outlined below.<br>Within the assessment, my business
            requires a level of health monitoring that includes:</p>


        <ul>
            <li>Demographic, medical and occupational history</li>
            <li>Records of personal exposure</li>
            <li>Standardised respiratory questionnaire</li>
            <li>Standardised respiratory function test, including FEV1, FVC, FEV1/FVC - it is strongly recommended this testing
                be undertaken by an accredited respiratory function laboratory and include testing of diffusing capacity.
            </li>
            <li>Chest X-ray full-size PA view - it is strongly recommended an ILO X-ray be undertaken to allow for reading by a
                B-reader.
            </li>
        </ul>


        <p>Please include a confirmation in your report that all requirements of the standard have been met.</p>
    </div>

</body>
</html>';

$mpdf = new \Mpdf\Mpdf($config);
$mpdf->WriteHTML($htmlContent);
$mpdf->Output();

enter image description here

Don't know what happens on unexpected bold text after the second table.

I have a bunch of attempt editing the html. I could replicate the problem that when I put piece of bold text between two tables. Could anyone help with if the bold text exists between two tables and keep the normal text after the second table?

php

mpdf

0 Answers

Your Answer

Accepted video resources