PDF page has no margin

Hi,

attached i have two pdfs, one generated by the internal pdf generator and another i printed to pdf with a pdf printer.

I like the way it looks with the pdf generator because from there i can send via outlook and print to my printer and it would look the same, but i would like to see some page margins please

could you please help me

Manager is not a what-you-see-is-what-you-get program. Your screen view is rendered by a browser from HTML. The PDF is generated by an internal PDF generator from the same HTML, but font substitutions are made to accommodate 80 or so languages. When printing, you are at the mercy of your operating system and printer driver(s). So you cannot expect all versions to look the same across all platforms and browsers.

You have chosen a theme that includes no built-in margins. The fact that margins appear when printing (to PDF or otherwise) is a function of your printer driver, to accommodate physical limits of the printer.

If you want margins when using the PDF button directly, you will have to create a custom theme and adjust the padding. You are responsible for programming and performance of any custom themes.

1 Like

I took a quick HTML course and changed my theme to always make a margin by adding the whole table inside a table. I am adding the code below if someone else also wants to do this

<table style="border:30px solid white">
<tr>
<td>
<table style="border:4px solid black">
    <thead>
        <tr>
            <td colspan="80">
                <div style="font-weight: bold; font-size: 32px; padding: 20px; background-color: #4472C4; color: #fff; margin-bottom: 20px; border-bottom-width: 3px; border-color: #B4C6E7">{{ title }}</div>
                
                <table style="margin-bottom: 20px"><tr>
                    <td style="padding-left: 30px">
                        <div style="font-weight: bold">{{ recipient.name }}</div>
                        <div>{{ recipient.address | newline_to_br }}</div>
                        <div>{{ recipient.identifier }}</div>
                    </td>
                    <td style="padding-right: 30px">
                        {% for field in fields %}
                        <div style="font-weight: bold">{{ field.label }}</div>
                        <div style="margin-bottom: 10px">{{ field.text }}</div>
                        {% endfor %}
                    </td>
                    {% if business.logo != null %}<td style="text-align: centre; width: 300px"><img src="{{ business.logo }}" style="max-height: 150px; max-width: 300px" /></td>{% endif %}
                </tr></table>

                <div style="font-size: 14px; font-weight: bold; margin-bottom: 20px; padding: 0px 30px">{{ description }}</div>
            </td>
        </tr>
        <tr>
            {% for column in table.columns %}            
            <td style="font-weight: bold; color: #ffffff; background-color: #4472C4; border-bottom-width: 5px; border-color: #B4C6E7; padding: 10px; text-align: {{ column.align }}{% if forloop.first %}; padding-left: 30px{% endif %}{% if forloop.last %}; padding-right: 30px{% 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: 10px; text-align: {{ table.columns[forloop.index0].align }}; border-color: #B4C6E7; border-bottom-width: 1px{% if forloop.first %}; padding-left: 30px{% endif %}{% if forloop.last %}; padding-right: 30px{% endif %}{% if table.columns[forloop.index0].nowrap %}; white-space: nowrap; width: 80px{% endif %}">{{ cell.text | newline_to_br }}</td>
            {% endfor %}
        </tr>
        {% endfor %}
        {% for total in table.totals %}
        <tr>
            <td colspan="{{ table.columns | size | minus:1 }}" style="padding: 10px; text-align: right{% if total.emphasis == true %}; font-weight: bold; font-size: 16px{% endif %}">{{ total.label }}</td>
            <td style="border-bottom-width: 1px; border-color: #B4C6E7; white-space: nowrap; padding: 10px; padding-left: 30px; text-align: right; padding-right: 30px{% if total.emphasis == true %}; font-weight: bold; color: #ffffff; background-color: #4472C4; font-size: 16px{% endif %}">{{ total.text }}</td>
        </tr>
        {% endfor %}
      


    </tbody>
      <tfoot>
       <tr><td><br><br><br><br></td></tr>
            <tr>
            <td colspan="99" style="padding-left: 30px; padding-right: 30px; text-align: center">
                {% for field in custom_fields %}
                <div style="font-weight: bold; font size: 13px">{{ field.label }}</div>
                <div style="padding-bottom: 20px">{{ field.text | newline_to_br }}</div>
                {% endfor %}
            </td>
        </tr>
        <tr><td colspan="99" style="padding-top: 20px">
            <div style="border-top-width: 3px; border-color: #B4C6E7; font-size: 12px; padding: 10px 20px; background-color: #4472C4; color: #fff">
                <div style="font-weight: bold; text-align: center; font size: 15px">{{ business.name }}</div>
                <div  style="font-weight: bold; text-align: center">{{ business.address | replace: "\n", " " }}</div>
                {% for field in business.custom_fields %}
                <div>{{ field.label }} {{ field.text }}</div>
                {% endfor %}
            </div>
        </td></tr>
    </tfoot>
</table>
</td>
</tr>
</table>

1 Like

Mooi. Dankjewel! Thanks

Hello dear, I tried testing your shared template. It appears it does not work for documents that are 2 pages or longer. The PDF generator only generates documents with the first page. Is there a way to fix this?

I don’t think that this :point_down: is the problem.

One of main purposes of the internal PDF generator is better multipage support.

However, your specific problem reminds me of another issue where the user created a field (or a custom field, it doesn’t really matter) that spans multiple pages. This breaks the internal PDF generator.

The question is do you have any field/custom field text that spans multiple pages?

I believe no. other themes works fine with the PDF generator when keeping the same custom fields.

@Taha_El_Zein, post screen shots of:

  • an example that does not work as you expect in the custom theme
  • the same transaction in the built-in Plain theme.