spipu / html2pdf

OFFICIAL PROJECT | HTML to PDF converter written in PHP
http://html2pdf.fr/en/default
Open Software License 3.0
1.67k stars 745 forks source link

Probeme in the second page of PDF generated #477

Open Bruno93160 opened 5 years ago

Bruno93160 commented 5 years ago

Hi,

I'm using html2pdf 5.2.1 with PHP 5.5.9

For the two exemple, there is the same image in the first page.

This a PDF generation with no problem with the second page : PDF1

In some case, there is a generation problem with the second page : PDF2

This is my code :

<page backtop="5mm" backbottom="15mm" backleft="5mm" backright="5mm">
    <page_footer>
        <table style="width: 100%;">
            <tr>
                <td style="text-align: left; width: 50%"><b>Compte-rendu généré le {{ downloadDate | date("d/m/Y à H:i") }}</b></td>
                <td style="text-align: right; width: 50%"><img style="position: fixed; bottom: 10px; right: 20px;" src="{{ lestaffLogoPAth }}" height="40"/></td>
            </tr>
        </table>
    </page_footer>
    <div style="width: 700px;">
        {% if image %}
        <img style="max-width:180px; max-height:950px; float: left;" src="{{ image }}">
        <div style="width: 500px;">
        {% else %}
        <div style="width: 700px;">
        {% endif %}
            <h2 style="text-align: center; color: #009e7e;">Compte-rendu de staff</h2>
            <h2 style="text-align: center;">{{ name }}</h2>
            <br/>

            <h3 style="color: #009e7e;">Informations générales</h3>
            <p>Session du {{ sessionStart | date("d/m/Y") }} au {{ sessionEnd | date("d/m/Y") }}</p>
            <p>Coordinateur du staff : {% if owner.roles[0] != 'ROLE_INSTITUTIONAL' and owner.roles[0] != 'ROLE_RESTRICTED_INSTITUTIONAL' %}Dr {% endif %}{{ owner.lastname }} {{ owner.firstname }}</p>
            {% if managers|length > 0 %}
                <p>Administrateur(s) du staff : {% for key, manager in managers %}{% if manager.roles[0] != 'ROLE_INSTITUTIONAL' and manager.roles[0] != 'ROLE_RESTRICTED_INSTITUTIONAL' %}Dr {% endif %}{{ manager.lastname }} {{ manager.firstname }}{% if managers|length > (key + 1) %}, {% endif %}{% endfor %}</p>
            {% endif %}
            {% if participants|length > 0 %}
                <p>Médecin{% if participants|length > 1 %}s{% endif %} ayant participé à la session :</p>
                <ul>
                    {% for member in participants %}
                      <li>{% if member.roles[0] != 'ROLE_INSTITUTIONAL' and member.roles[0] != 'ROLE_RESTRICTED_INSTITUTIONAL' %}Dr {% endif %}{{ member.lastname }} {{ member.firstname }} {% if member.speciality %}({{ member.speciality }}){% endif %}</li>
                    {% endfor %}
                </ul>
            {% endif %}

            {% if staffReviews|length > 0 %}
                <br/>
                <h3 style="color: #009e7e;">Avis du staff</h3>
                {% for staffReview in staffReviews %}
                    <p><b>{{ staffReview.patient.fullName }}</b> ({{ staffReview.patient.birthdate }}) créé le {{ staffReview.patient.createdAt | date("d/m/Y à H:i") }}</p>
                    <p>{% if staffReview.patient.freeDiagnostic %}Diagnostic : {{ staffReview.patient.freeDiagnostic }} ; {% endif %}Médecin responsable : {% if not staffReview.patient.isDoctorInstitutional %}Dr {% endif %}{{ staffReview.patient.doctorFullName }}</p>
                    {% if staffReview.patient.logEntries|length > 0 %}
                        <p>Anamnèse :</p>
                        {% for logEntry in staffReview.patient.logEntries %}
                            <p style="width: 500px; white-space: pre-wrap; word-break: break-all;"><b>{{ logEntry.date }}</b> : {{ logEntry.description | raw }}</p>
                        {% endfor %}
                    {% endif %}
                    {% if staffReview.patient.customFields|length > 0 %}
                        <p>Informations complémentaires :</p>
                        {% for customFieldsFirst in staffReview.patient.customFields %}
                            {% if customFieldsFirst.children is defined %}
                                <div>{{ customFieldsFirst.label }}</div>
                                {% for customFieldsSecond in customFieldsFirst.children %}
                                    {% if customFieldsSecond.children is defined %}
                                        <div style="margin-left: 15px;">{{ customFieldsSecond.label }}</div>
                                        {% for customFieldsThird in customFieldsSecond.children %}
                                            {% if customFieldsThird.children is defined %}
                                                <div style="margin-left: 30px">{{ customFieldsThird.label }}</div>
                                                {% for customFieldsForth in customFieldsThird.children %}
                                                    {% if customFieldsForth.children is defined %}
                                                        <div style="margin-left: 45px">{{ customFieldsForth.label }}</div>
                                                        {% for customFieldsFifth in customFieldsForth.children %}
                                                            {% if customFieldsFifth.children is defined %}
                                                                <div style="margin-left: 60px">{{ customFieldsFifth.label }}</div>
                                                                {% for customFieldsSixth in customFieldsFifth.children %}
                                                                    {% if customFieldsSixth.children is defined %}
                                                                        <div style="margin-left: 75px">{{ customFieldsSixth.label }}</div>
                                                                        {% for customFieldsSeventh in customFieldsSixth.children %}
                                                                            {% if customFieldsSeventh.children is defined %}
                                                                                <div style="margin-left: 90px">{{ customFieldsSeventh.label }}</div>
                                                                                {% for customFieldsEighth in customFieldsSeventh.children %}
                                                                                    <div style="margin-left: 105px">{{ customFieldsEighth.label }} : {{ customFieldsEighth.content }}</div>
                                                                                {% endfor %}
                                                                            {% else %}
                                                                                <div style="margin-left: 90px;">{{ customFieldsSeventh.label }} : {{ customFieldsSeventh.content }}</div>
                                                                            {% endif %}
                                                                        {% endfor %}
                                                                    {% else %}
                                                                        <div style="margin-left: 75px;">{{ customFieldsSixth.label }} : {{ customFieldsSixth.content }}</div>
                                                                    {% endif %}
                                                                {% endfor %}
                                                            {% else %}
                                                                <div style="margin-left: 60px;">{{ customFieldsFifth.label }} : {{ customFieldsFifth.content }}</div>
                                                            {% endif %}
                                                        {% endfor %}
                                                    {% else %}
                                                        <div style="margin-left: 45px;">{{ customFieldsForth.label }} : {{ customFieldsForth.content }}</div>
                                                    {% endif %}
                                                {% endfor %}
                                            {% else %}
                                                <div style="margin-left: 30px;">{{ customFieldsThird.label }} : {{ customFieldsThird.content }}</div>
                                            {% endif %}
                                        {% endfor %}
                                    {% else %}
                                        <div style="margin-left: 15px;">{{ customFieldsSecond.label }} : {{ customFieldsSecond.content }}</div>
                                    {% endif %}
                                {% endfor %}
                            {% else %}
                                <div>{{ customFieldsFirst.label }} : {{ customFieldsFirst.content }}</div>
                            {% endif %}
                        {% endfor %}
                    {% endif %}
                    {% for content in staffReview.contents %}
                        <p style="text-decoration: underline;">Avis posté le {{ content.createdAt | date("d/m/Y à H:i") }} :</p>
                        <p>{{ content.text | raw }}</p>
                    {% endfor %}
                    <br/>
                {% endfor %}
            {% endif %}
        </div>
    </div>
</page>

Have you an idea?

Sincerely, Bruno

LittleBigFox commented 5 years ago

Hi Bruno! Could you explain where is your problem? I've opened the two images in tabs, i didn't see the difference...

Regards, LBF

Bruno93160 commented 5 years ago

In the first image, between the first and the second page you can see all text is vertical align.

In the second image for the second page, the text begin at the right of page. and not vertical align like the first one.

Is that most clearly?

Regards, Bruno