Examples › Source code
Example source code
The complete HTML of every example in our gallery. Copy a file, save it as .html, and either open it in the HTML to PDF tool or render it on a server with mPDF:
<?php
require __DIR__ . '/vendor/autoload.php';
$html = file_get_contents(__DIR__ . '/invoice.html'); // any example below, saved as a file
$mpdf = new \Mpdf\Mpdf(['tempDir' => sys_get_temp_dir() . '/mpdf']);
$mpdf->WriteHTML($html);
$mpdf->Output('invoice.pdf', \Mpdf\Output\Destination::INLINE);New to mPDF? Start with the install guide.
Invoice
A one-page invoice with a header, line items and totals, laid out with tables. Open it in HTML to PDF.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Invoice INV-2026-041</title>
<style>
@page { size: A4; margin: 18mm 16mm; }
body { font-family: Helvetica, Arial, sans-serif; font-size: 10.5pt; color: #222; }
.head td { vertical-align: top; }
.brand { font-size: 20pt; font-weight: bold; color: #0e6b62; }
h1 { font-size: 26pt; margin: 0; text-align: right; color: #444; letter-spacing: 1px; }
.meta { text-align: right; color: #555; }
table { width: 100%; border-collapse: collapse; }
.parties { margin: 22px 0; }
.parties td { width: 50%; vertical-align: top; }
.label { font-size: 8.5pt; text-transform: uppercase; color: #888; letter-spacing: 1px; }
.items th { background: #0e6b62; color: #fff; text-align: left; padding: 7px 8px; font-size: 9.5pt; }
.items td { padding: 7px 8px; border-bottom: 1px solid #ddd; }
.items tr { break-inside: avoid; page-break-inside: avoid; }
.num { text-align: right; white-space: nowrap; }
.totals { width: 45%; margin-left: 55%; margin-top: 12px; }
.totals td { padding: 5px 8px; }
.grand td { font-weight: bold; font-size: 12pt; border-top: 2px solid #222; }
.note { margin-top: 30px; color: #555; font-size: 9pt; }
</style>
</head>
<body>
<table class="head"><tr>
<td><div class="brand">Northwind Studio</div>12 Harbour Lane<br>Bristol BS1 4ST<br>hello@northwind.example</td>
<td><h1>INVOICE</h1><div class="meta">No. INV-2026-041<br>Issued 2 November 2026<br>Due 2 December 2026</div></td>
</tr></table>
<table class="parties"><tr>
<td><div class="label">Bill to</div><strong>Lumen Bakery Ltd</strong><br>48 Market Street<br>Leeds LS1 6DT</td>
<td><div class="label">Project</div>Website refresh and print menu<br><div class="label" style="margin-top:8px">Payment</div>Bank transfer, 30 days</td>
</tr></table>
<table class="items">
<thead><tr><th>Description</th><th class="num">Qty</th><th class="num">Rate</th><th class="num">Amount</th></tr></thead>
<tbody>
<tr><td>Discovery workshop</td><td class="num">1</td><td class="num">£450.00</td><td class="num">£450.00</td></tr>
<tr><td>Homepage and menu page design</td><td class="num">3 days</td><td class="num">£520.00</td><td class="num">£1,560.00</td></tr>
<tr><td>Build and launch</td><td class="num">4 days</td><td class="num">£480.00</td><td class="num">£1,920.00</td></tr>
<tr><td>Print menu, A3, two rounds of edits</td><td class="num">1</td><td class="num">£380.00</td><td class="num">£380.00</td></tr>
</tbody>
</table>
<table class="totals">
<tr><td>Subtotal</td><td class="num">£4,310.00</td></tr>
<tr><td>VAT 20%</td><td class="num">£862.00</td></tr>
<tr class="grand"><td>Total due</td><td class="num">£5,172.00</td></tr>
</table>
<p class="note">Please quote the invoice number with your payment. Thank you for your business.</p>
</body>
</html>Formal letter
A plain business letter with the sender block on the right and generous margins. Open it in HTML to PDF.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Letter</title>
<style>
@page { size: A4; margin: 25mm 24mm; }
body { font-family: Georgia, 'Times New Roman', serif; font-size: 11.5pt; line-height: 1.55; color: #1d1d1d; }
.sender { text-align: right; font-size: 10pt; color: #555; margin-bottom: 36px; }
.date { margin: 28px 0; }
p { margin: 0 0 12px; }
.sign { margin-top: 36px; }
</style>
</head>
<body>
<div class="sender">Sam Patel<br>7 Linden Road<br>Cambridge CB2 1QX</div>
<div>Customer Services<br>Riverside Energy<br>PO Box 210<br>Manchester M60 1AB</div>
<div class="date">2 November 2026</div>
<p><strong>Account 55102-884: request for a final meter reading</strong></p>
<p>Dear Customer Services,</p>
<p>I moved out of 7 Linden Road on 31 October 2026 and would like to close the account above. The final meter reading, taken that morning, was 041872.</p>
<p>Please send the closing statement to my new address at the top of this letter, and refund any credit to the card on file.</p>
<p>Thank you for your help.</p>
<div class="sign">Yours faithfully,<br><br><br>Sam Patel</div>
</body>
</html>Multi-page report
A cover page, chapters that start on new pages, a KPI row and a table kept in one piece. Open it in HTML to PDF.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Quarterly report</title>
<style>
@page { size: A4; margin: 20mm 18mm; }
body { font-family: Helvetica, Arial, sans-serif; font-size: 10.5pt; line-height: 1.5; color: #222; }
.cover { text-align: center; padding-top: 180px; }
.cover h1 { font-size: 30pt; margin-bottom: 6px; color: #0e6b62; }
.cover p { color: #666; font-size: 13pt; }
h2 { font-size: 16pt; color: #0e6b62; border-bottom: 2px solid #0e6b62; padding-bottom: 4px; break-before: page; page-break-before: always; }
h2:first-of-type { break-before: page; }
table { width: 100%; border-collapse: collapse; margin: 12px 0; }
th, td { border: 1px solid #ccc; padding: 6px 8px; text-align: left; }
th { background: #eef5f4; }
.num { text-align: right; }
.kpi td { border: 0; text-align: center; width: 33%; }
.kpi strong { display: block; font-size: 22pt; color: #0e6b62; }
.keep { break-inside: avoid; page-break-inside: avoid; }
</style>
</head>
<body>
<div class="cover">
<h1>Quarterly report</h1>
<p>Q3 2026 · Operations team</p>
</div>
<h2>1. Summary</h2>
<table class="kpi"><tr>
<td><strong>94%</strong>orders shipped on time</td>
<td><strong>2.1 days</strong>average dispatch</td>
<td><strong>−8%</strong>returns versus Q2</td>
</tr></table>
<p>Dispatch times improved after the warehouse moved to two shifts in August. Returns fell, mostly in the sizing-sensitive categories, after the new size guide went live.</p>
<h2>2. Orders by region</h2>
<div class="keep">
<table>
<thead><tr><th>Region</th><th class="num">Orders</th><th class="num">On time</th><th class="num">Returns</th></tr></thead>
<tbody>
<tr><td>North</td><td class="num">4,820</td><td class="num">95%</td><td class="num">3.1%</td></tr>
<tr><td>Midlands</td><td class="num">6,104</td><td class="num">93%</td><td class="num">3.6%</td></tr>
<tr><td>South</td><td class="num">8,377</td><td class="num">94%</td><td class="num">2.9%</td></tr>
<tr><td>Scotland and Wales</td><td class="num">2,215</td><td class="num">92%</td><td class="num">3.3%</td></tr>
</tbody>
</table>
</div>
<p>Each chapter starts on a new page because of the <code>page-break-before</code> rule on <code>h2</code>; the table is kept in one piece with <code>page-break-inside: avoid</code>.</p>
<h2>3. Next quarter</h2>
<ul>
<li>Extend the second shift to Saturdays from December.</li>
<li>Trial pre-printed returns labels in the South region.</li>
<li>Report dispatch time by carrier, not only by region.</li>
</ul>
</body>
</html>Certificate
A landscape certificate with a double border and two signature lines. Open it in HTML to PDF.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Certificate</title>
<style>
@page { size: A4 landscape; margin: 12mm; }
body { font-family: Georgia, 'Times New Roman', serif; color: #1d2a33; }
.frame { border: 6px double #0e6b62; padding: 46px 40px; text-align: center; height: 150mm; }
.small { letter-spacing: 4px; text-transform: uppercase; font-size: 11pt; color: #0e6b62; }
h1 { font-size: 34pt; margin: 14px 0 26px; font-weight: normal; }
.name { font-size: 28pt; font-style: italic; border-bottom: 1px solid #999; display: inline-block; padding: 0 40px 6px; margin: 10px 0 22px; }
p { font-size: 13pt; margin: 6px 0; }
.foot { width: 100%; margin-top: 50px; }
.foot td { width: 50%; text-align: center; font-size: 10.5pt; color: #444; }
.line { border-top: 1px solid #777; width: 60%; margin: 0 auto 4px; }
</style>
</head>
<body>
<div class="frame">
<div class="small">Certificate of completion</div>
<h1>Introduction to Data Analysis</h1>
<p>This certifies that</p>
<div class="name">Jordan Lee</div>
<p>completed all six modules and the final project</p>
<p>with distinction, on 30 October 2026.</p>
<table class="foot"><tr>
<td><div class="line"></div>Course lead</td>
<td><div class="line"></div>Programme director</td>
</tr></table>
</div>
</body>
</html>Long price list
Sixty rows across pages, with the header row repeated on every page. Open it in HTML to PDF.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Price list</title>
<style>
@page { size: A4; margin: 16mm 14mm; }
body { font-family: Helvetica, Arial, sans-serif; font-size: 9.5pt; color: #222; }
h1 { font-size: 18pt; margin: 0 0 4px; }
.sub { color: #666; margin: 0 0 14px; }
table { width: 100%; border-collapse: collapse; }
thead { display: table-header-group; }
th { background: #222; color: #fff; padding: 6px; text-align: left; }
td { padding: 5px 6px; border-bottom: 1px solid #e3e3e3; }
tbody tr:nth-child(even) td { background: #f6f6f6; }
tr { page-break-inside: avoid; break-inside: avoid; }
.num { text-align: right; }
</style>
</head>
<body>
<h1>Trade price list</h1>
<p class="sub">Valid from 1 November 2026. Prices exclude VAT. The header row repeats on every page.</p>
<table>
<thead><tr><th>Code</th><th>Product</th><th>Pack</th><th class="num">Price</th></tr></thead>
<tbody>
<tr><td>NW-1001</td><td>Oak shelf bracket</td><td>each</td><td class="num">£2.40</td></tr>
<tr><td>NW-1002</td><td>Brass cabinet knob</td><td>pair</td><td class="num">£6.10</td></tr>
<tr><td>NW-1003</td><td>Steel hinge, 75 mm</td><td>box of 10</td><td class="num">£9.80</td></tr>
<tr><td>NW-1004</td><td>Wood screws, 4×40</td><td>box of 100</td><td class="num">£4.50</td></tr>
<tr><td>NW-1005</td><td>Wall plug, 6 mm</td><td>bag of 50</td><td class="num">£8.20</td></tr>
<tr><td>NW-1006</td><td>Felt pads, assorted</td><td>pack of 24</td><td class="num">£2.90</td></tr>
<tr><td>NW-1007</td><td>Oak shelf bracket</td><td>each</td><td class="num">£6.60</td></tr>
<tr><td>NW-1008</td><td>Brass cabinet knob</td><td>pair</td><td class="num">£10.30</td></tr>
<tr><td>NW-1009</td><td>Steel hinge, 75 mm</td><td>box of 10</td><td class="num">£5.00</td></tr>
<tr><td>NW-1010</td><td>Wood screws, 4×40</td><td>box of 100</td><td class="num">£8.70</td></tr>
<tr><td>NW-1011</td><td>Wall plug, 6 mm</td><td>bag of 50</td><td class="num">£3.40</td></tr>
<tr><td>NW-1012</td><td>Felt pads, assorted</td><td>pack of 24</td><td class="num">£7.10</td></tr>
<tr><td>NW-1013</td><td>Oak shelf bracket</td><td>each</td><td class="num">£10.80</td></tr>
<tr><td>NW-1014</td><td>Brass cabinet knob</td><td>pair</td><td class="num">£5.50</td></tr>
<tr><td>NW-1015</td><td>Steel hinge, 75 mm</td><td>box of 10</td><td class="num">£9.20</td></tr>
<tr><td>NW-1016</td><td>Wood screws, 4×40</td><td>box of 100</td><td class="num">£3.90</td></tr>
<tr><td>NW-1017</td><td>Wall plug, 6 mm</td><td>bag of 50</td><td class="num">£7.60</td></tr>
<tr><td>NW-1018</td><td>Felt pads, assorted</td><td>pack of 24</td><td class="num">£11.30</td></tr>
<tr><td>NW-1019</td><td>Oak shelf bracket</td><td>each</td><td class="num">£6.00</td></tr>
<tr><td>NW-1020</td><td>Brass cabinet knob</td><td>pair</td><td class="num">£9.70</td></tr>
<tr><td>NW-1021</td><td>Steel hinge, 75 mm</td><td>box of 10</td><td class="num">£4.40</td></tr>
<tr><td>NW-1022</td><td>Wood screws, 4×40</td><td>box of 100</td><td class="num">£8.10</td></tr>
<tr><td>NW-1023</td><td>Wall plug, 6 mm</td><td>bag of 50</td><td class="num">£2.80</td></tr>
<tr><td>NW-1024</td><td>Felt pads, assorted</td><td>pack of 24</td><td class="num">£6.50</td></tr>
<tr><td>NW-1025</td><td>Oak shelf bracket</td><td>each</td><td class="num">£10.20</td></tr>
<tr><td>NW-1026</td><td>Brass cabinet knob</td><td>pair</td><td class="num">£4.90</td></tr>
<tr><td>NW-1027</td><td>Steel hinge, 75 mm</td><td>box of 10</td><td class="num">£8.60</td></tr>
<tr><td>NW-1028</td><td>Wood screws, 4×40</td><td>box of 100</td><td class="num">£3.30</td></tr>
<tr><td>NW-1029</td><td>Wall plug, 6 mm</td><td>bag of 50</td><td class="num">£7.00</td></tr>
<tr><td>NW-1030</td><td>Felt pads, assorted</td><td>pack of 24</td><td class="num">£10.70</td></tr>
<tr><td>NW-1031</td><td>Oak shelf bracket</td><td>each</td><td class="num">£5.40</td></tr>
<tr><td>NW-1032</td><td>Brass cabinet knob</td><td>pair</td><td class="num">£9.10</td></tr>
<tr><td>NW-1033</td><td>Steel hinge, 75 mm</td><td>box of 10</td><td class="num">£3.80</td></tr>
<tr><td>NW-1034</td><td>Wood screws, 4×40</td><td>box of 100</td><td class="num">£7.50</td></tr>
<tr><td>NW-1035</td><td>Wall plug, 6 mm</td><td>bag of 50</td><td class="num">£11.20</td></tr>
<tr><td>NW-1036</td><td>Felt pads, assorted</td><td>pack of 24</td><td class="num">£5.90</td></tr>
<tr><td>NW-1037</td><td>Oak shelf bracket</td><td>each</td><td class="num">£9.60</td></tr>
<tr><td>NW-1038</td><td>Brass cabinet knob</td><td>pair</td><td class="num">£4.30</td></tr>
<tr><td>NW-1039</td><td>Steel hinge, 75 mm</td><td>box of 10</td><td class="num">£8.00</td></tr>
<tr><td>NW-1040</td><td>Wood screws, 4×40</td><td>box of 100</td><td class="num">£2.70</td></tr>
<tr><td>NW-1041</td><td>Wall plug, 6 mm</td><td>bag of 50</td><td class="num">£6.40</td></tr>
<tr><td>NW-1042</td><td>Felt pads, assorted</td><td>pack of 24</td><td class="num">£10.10</td></tr>
<tr><td>NW-1043</td><td>Oak shelf bracket</td><td>each</td><td class="num">£4.80</td></tr>
<tr><td>NW-1044</td><td>Brass cabinet knob</td><td>pair</td><td class="num">£8.50</td></tr>
<tr><td>NW-1045</td><td>Steel hinge, 75 mm</td><td>box of 10</td><td class="num">£3.20</td></tr>
<tr><td>NW-1046</td><td>Wood screws, 4×40</td><td>box of 100</td><td class="num">£6.90</td></tr>
<tr><td>NW-1047</td><td>Wall plug, 6 mm</td><td>bag of 50</td><td class="num">£10.60</td></tr>
<tr><td>NW-1048</td><td>Felt pads, assorted</td><td>pack of 24</td><td class="num">£5.30</td></tr>
<tr><td>NW-1049</td><td>Oak shelf bracket</td><td>each</td><td class="num">£9.00</td></tr>
<tr><td>NW-1050</td><td>Brass cabinet knob</td><td>pair</td><td class="num">£3.70</td></tr>
<tr><td>NW-1051</td><td>Steel hinge, 75 mm</td><td>box of 10</td><td class="num">£7.40</td></tr>
<tr><td>NW-1052</td><td>Wood screws, 4×40</td><td>box of 100</td><td class="num">£11.10</td></tr>
<tr><td>NW-1053</td><td>Wall plug, 6 mm</td><td>bag of 50</td><td class="num">£5.80</td></tr>
<tr><td>NW-1054</td><td>Felt pads, assorted</td><td>pack of 24</td><td class="num">£9.50</td></tr>
<tr><td>NW-1055</td><td>Oak shelf bracket</td><td>each</td><td class="num">£4.20</td></tr>
<tr><td>NW-1056</td><td>Brass cabinet knob</td><td>pair</td><td class="num">£7.90</td></tr>
<tr><td>NW-1057</td><td>Steel hinge, 75 mm</td><td>box of 10</td><td class="num">£2.60</td></tr>
<tr><td>NW-1058</td><td>Wood screws, 4×40</td><td>box of 100</td><td class="num">£6.30</td></tr>
<tr><td>NW-1059</td><td>Wall plug, 6 mm</td><td>bag of 50</td><td class="num">£10.00</td></tr>
<tr><td>NW-1060</td><td>Felt pads, assorted</td><td>pack of 24</td><td class="num">£4.70</td></tr>
</tbody>
</table>
</body>
</html>Multilingual notice
The same notice in six languages, including Arabic (right to left), Greek and Japanese. Open it in HTML to PDF.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Multilingual notice</title>
<style>
@page { size: A4; margin: 20mm; }
body { font-family: 'DejaVu Sans', 'Noto Sans', 'Segoe UI', Arial, sans-serif; font-size: 12pt; line-height: 1.6; }
h1 { font-size: 18pt; }
.block { border: 1px solid #ddd; border-radius: 6px; padding: 10px 14px; margin: 10px 0; }
.label { font-size: 8.5pt; color: #888; text-transform: uppercase; letter-spacing: 1px; }
</style>
</head>
<body>
<h1>Opening hours / Horaires / Öffnungszeiten</h1>
<div class="block"><div class="label">English</div>The library is open Monday to Saturday, 9:00 to 18:00.</div>
<div class="block" lang="fr"><div class="label">Français</div>La bibliothèque est ouverte du lundi au samedi, de 9 h à 18 h.</div>
<div class="block" lang="de"><div class="label">Deutsch</div>Die Bibliothek ist von Montag bis Samstag von 9 bis 18 Uhr geöffnet.</div>
<div class="block" lang="el"><div class="label">Ελληνικά</div>Η βιβλιοθήκη είναι ανοιχτή από Δευτέρα έως Σάββατο, 9:00 έως 18:00.</div>
<div class="block" lang="ar" dir="rtl"><div class="label">العربية</div>المكتبة مفتوحة من الاثنين إلى السبت، من الساعة 9:00 حتى 18:00.</div>
<div class="block" lang="ja"><div class="label">日本語</div>図書館は月曜日から土曜日の9時から18時まで開館しています。</div>
</body>
</html>