DESKTOP EDITION CLOUD EDITION SERVER EDITION GUIDES FORUM

PDF creation not consistently

#1

Hi,

I am sending invoices by creating an email. The layout of the PDF differs. Somtimes it is correct and sometimes all the text is on left side of the page. I have sent a bunch of invoices and about 50% is like the following invoice:

The other 50% is the correct layout like:
02

When I resend the faulty invoice using the email function again, then sometimes the layout is correct. (The first invoice after restarting of the application seems to be correct everytime, maybe some code is taken to the next pdf generation).
The code is as follows:

<table style="padding: 30px">
    <thead>
        <tr>
            <td colspan="99">
                <table style="margin-bottom: 20px"><tr>
                    <td style="font-weight: bold; font-size: 32px">{{ title }}</td>
                    {% if business.logo != null %}<td style="text-align: right"><img src="{{ business.logo }}" style="max-height: 150px; max-width: 300px" /></td>{% endif %}
                </tr></table>
                
                <table style="margin-bottom: 20px"><tr>
                    <td>
                        <div><b>{{ recipient.name }}</b> Lidnr: {{ recipient.code }}</div>
                        <div>{{ recipient.address | newline_to_br }}</div>
                        <div>{{ recipient.identifier }}</div>
                    </td>
                    <td style="border-right-width: 1px; padding-right: 20px; text-align: right">
                        {% for field in fields %}
                        <div style="font-weight: bold">{{ field.label }}</div>
                        <div style="margin-bottom: 10px">{{ field.text }}</div>
                        {% endfor %}
                    </td>
                    <td style="padding-left: 20px; width: 1px; white-space: nowrap">
                        <div style="font-weight: bold">{{ business.name }}</div>
                        <div>{{ business.address | newline_to_br }}</div>
                        <div>{{ business.identifier }}</div>
                    </td>
                </tr></table>

                <div style="font-size: 14px; font-weight: bold; margin-bottom: 20px">{{ description }}</div>
            </td>
        </tr>
        <tr>
            {% for column in table.columns %}            
            <td style="font-weight: bold; padding: 5px 10px; text-align: {{ column.align }}; border-left-width: 1px; border-bottom-width: 1px; border-top-width: 1px{% if forloop.last == true %}; border-right-width: 1px{% endif %}{% if column.nowrap %}; width: 80px{% endif %}">{{ column.label }}</td>
            {% endfor %}
        </tr>
    </thead>
    <tbody>
        {% for row in table.rows %}
        <tr>
            {% for cell in row.cells %}
            <td style="padding: 5px 10px; text-align: {{ table.columns[forloop.index0].align }}; border-left-width: 1px{% if forloop.last == true %}; border-right-width: 1px{% endif %}{% if table.columns[forloop.index0].nowrap %}; white-space: nowrap; width: 80px{% endif %}">{{ cell.text | newline_to_br }}</td>
            {% endfor %}
        </tr>
        {% endfor %}
        <tr>
        {% for column in table.columns %}            
            <td style="border-bottom-width: 1px; border-left-width: 1px{% if forloop.last == true %}; border-right-width: 1px{% endif %}">&nbsp;</td>
        {% endfor %}
        </tr>
        {% for total in table.totals %}
        <tr>
            <td colspan="{{ table.columns | size | minus:1 }}" style="padding: 5px 10px; text-align: right{% if total.emphasis == true %}; font-weight: bold{% endif %}">{{ total.label }}</td>
            <td style="border-left-width: 1px; white-space: nowrap; border-right-width: 1px; border-bottom-width: 1px; padding: 5px 10px; text-align: right{% if total.emphasis == true %}; font-weight: bold{% endif %}">{{ total.text }}</td>
        </tr>
        {% endfor %}
        <tr>
            <td colspan="99">
                <div style="font-weight: normal; padding-top: 20px">Het bedrag voor de vervaldatum onder vermelding van factuurnummer en uw lidnummer overmaken op rekeningnummer <b>NLXXRBRBXXXXXXXXXXX</b> t.n.v. <b>ATV de Trambrug</b> te schipluiden</div>
            </td>
        </tr>

        {% for field in custom_fields %}
        <tr>
            <td colspan="99">
                <div style="font-weight: bold; padding-top: 20px">{{ field.label }}</div>
                <div>{{ field.text | newline_to_br }}</div>
            </td>
        </tr>
        {% endfor %}

        {% if emphasis.text != null and emphasis.positive %}
        <tr><td colspan="99"><div style="text-align: center; margin-top: 40px"><span style="color: #006400; border-width: 5px; border-color: #006400; padding: 10px; font-size: 20px">{{ emphasis.text | upcase }}</span></div></td></tr>
        {% endif %}

        {% if emphasis.text != null and emphasis.negative %}
        <tr><td colspan="99"><div style="text-align: center; margin-top: 40px"><span style="color: #FF0000; border-width: 5px; border-color: #FF0000; padding: 10px; font-size: 20px">{{ emphasis.text | upcase }}</span></div></td></tr>
        {% endif %}
            
    </tbody>
</table>
0 Likes

#2

are you using the default in-built theme or have you customized theme?
the code you have provided looks like a customized theme.

help will be provided on the forum for issues related to default in-built themes. do you have above mentioned issues when you use the default in-built themes?
custom themes are the responsibility of users and it is upto the user to troubleshoot issues arising from the same.

0 Likes

#3

I adjusted the default built in theme. It has been long time since I did the adjustments, I can remember the following:

  • Add the payment specifications line under.
  • changed the spacing values for the vertical line to get more space on the right side of the line.
  • Maybe some small adjustments
0 Likes

#4

Indeed, custom themes are the responsibility of users.
Nevertheless, you could have a look at this piece of code:

td style=“padding-left: 20px; width: 1px; white-space: nowrap”>

{{ business.name }}</div
{{ business.address | newline_to_br }}</div
{{ business.identifier }}</div
</td

Change it to
width: 200px;

And have a look at your logo. Make sure the image is smaller than the maximum.

Also, add html code <br> in:
Het bedrag voor de vervaldatum onder vermelding van factuurnummer en uw lidnummer overmaken op rekeningnummer NLXXRBRBXXXXXXXXXXX t.n.v. ATV de Trambrug te schipluiden

For instance:
Het bedrag voor de vervaldatum onder vermelding van factuurnummer en uw lidnummer overmaken op <br> rekeningnummer NLXXRBRBXXXXXXXXXXX t.n.v. ATV de Trambrug te schipluiden
in order to make the line break hard coded.

Hope it helps.

0 Likes

#5

It seems after removing the statement “white-space: nowrap” the generation is everytime the same again. I changed the width of the 3 columns which gave back a good looking invoice header.

Thanks for the help.

0 Likes

#6

Top!

Be aware by removing “white-space: nowrap” you may still have to take care of the line breaks, if not now then maybe in the future.
I saw you have a long business name and bankaccount etc…
In order to break a line you can use <br> in your business data, see underneath.

0 Likes