Stop the invoice printing my own indentation
tests / pest (push) Failing after 8m3s Details
tests / assets (push) Successful in 21s Details
tests / release (push) Has been skipped Details

TCPDF takes leading whitespace in HTML literally, so every line of the address
and every line description came out indented by however far the Blade template
happened to be nested — and the one line that had no indentation, the VAT
number, sat flush against the margin looking like the mistake. It was the only
correct one.

Also puts the title and the invoice number in one block. As an h1 with a
paragraph beneath it, TCPDF gave the heading a margin of its own and the two
drifted a centimetre apart.

Found by rendering the page and looking at it, which is the only way any of
this is ever found.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
feat/granted-plans
nexxo 2026-07-29 01:45:55 +02:00
parent c1896e70fc
commit f8c923b48a
1 changed files with 10 additions and 17 deletions

View File

@ -32,15 +32,10 @@
<table cellpadding="0" cellspacing="0" style="width:100%; margin-top:2mm;">
<tr>
<td style="width:58%; font-size:10pt; line-height:145%;">
<b>{{ $customer['name'] ?? '' }}</b><br>
{{ $customer['address'] ?? '' }}<br>
{{ trim(($customer['postcode'] ?? '').' '.($customer['city'] ?? '')) }}<br>
{{ $customer['country'] ?? '' }}
@if (! empty($customer['vat_id']))
<br>{{ __('invoice.customer_vat') }}: {{ $customer['vat_id'] }}
@endif
</td>
{{-- No leading whitespace inside these cells. TCPDF prints it: every indented
line came out indented, and only the last one which had none sat flush
against the margin. --}}
<td style="width:58%; font-size:10pt; line-height:145%;"><b>{{ $customer['name'] ?? '' }}</b><br>{{ $customer['address'] ?? '' }}<br>{{ trim(($customer['postcode'] ?? '').' '.($customer['city'] ?? '')) }}<br>{{ $customer['country'] ?? '' }}@if (! empty($customer['vat_id']))<br>{{ __('invoice.customer_vat') }}: {{ $customer['vat_id'] }}@endif</td>
<td style="width:42%;"></td>
</tr>
</table>
@ -66,8 +61,11 @@
@endif
</table>
<h1 style="font-size:17pt; margin-top:10mm; margin-bottom:0;">{{ $meta['title'] ?? __('invoice.title') }}</h1>
<p style="font-size:17pt; margin-top:0;">{{ $meta['number'] ?? '' }}</p>
{{-- One block, not a heading with a paragraph beneath it: TCPDF gives an h1 a
margin of its own and the two drifted a centimetre apart. --}}
<table cellpadding="0" cellspacing="0" style="width:100%; margin-top:9mm;">
<tr><td style="font-size:16pt; font-weight:bold; line-height:125%;">{{ $meta['title'] ?? __('invoice.title') }}<br>{{ $meta['number'] ?? '' }}</td></tr>
</table>
@if (! empty($meta['salutation']))
<p style="font-size:9.5pt; margin-top:6mm;">{{ $meta['salutation'] }}</p>
@ -95,12 +93,7 @@
@endphp
<tr>
<td style="border-bottom:0.1mm solid #e9e9ee;">{{ $index + 1 }}</td>
<td style="border-bottom:0.1mm solid #e9e9ee;">
{{ $line['description'] ?? '' }}
@foreach (($line['details'] ?? []) as $detail)
<br><span style="color:#6e6e7a;">{{ $detail }}</span>
@endforeach
</td>
<td style="border-bottom:0.1mm solid #e9e9ee;">{{ $line['description'] ?? '' }}@foreach (($line['details'] ?? []) as $detail)<br><span style="color:#6e6e7a;">{{ $detail }}</span>@endforeach</td>
<td style="text-align:right; border-bottom:0.1mm solid #e9e9ee;">{{ InvoiceMath::quantity((int) $line['quantity_milli']) }}@if (! empty($line['unit'])) {{ $line['unit'] }}@endif</td>
<td style="text-align:right; border-bottom:0.1mm solid #e9e9ee;">{{ InvoiceMath::money((int) $line['unit_net_cents']) }}</td>
<td style="text-align:right; border-bottom:0.1mm solid #e9e9ee;">{{ InvoiceMath::money($net) }}</td>