Home / Documentation
A complete reference for building PDFs in getpdfcode — every component and property, fonts, dynamic data, and exactly which features each library supports.
Create a free account and open your dashboard.
New project — start from a blank A4 canvas or a starter template.
You're in the builder: components on the left, the canvas in the middle, the properties panel on the right, and a Preview tab that renders the real PDF.
You build a document from content elements placed inside structure (rows and columns).
| Component | What it is |
|---|---|
| Text | Rich-text paragraph — the default element. Holds formatted text, tokens, bound variables and inline conditions; see Rich text editor. |
| Heading / H1–H6 | Bold heading. H1–H6 are semantic levels with preset sizes; “Heading” is a generic bold block. |
| List | A simple bulleted list. |
| Divider | A rule to separate sections — horizontal or vertical. Colour, thickness and style; single, double or thin/thick pairs; any length, aligned left, centre or right; and an optional caption or ornament set into the line. |
| Image | A raster image you upload — JPG, PNG, GIF or WebP, up to 10 MB. |
| Table / Grid | An R×C grid of cells — a nested table you fill with content. |
| QR code | A QR code from any text/URL, with selectable error-correction level and size. |
| Barcode | 1D & 2D barcodes (Code 128, EAN, UPC, Code 39, PDF417, DataMatrix and more) with an optional label. |
| Blank | An underlined fill-in-the-blank space of N characters — for printable forms. |
| Signature line | A signing line with a caption underneath (a design element — not a cryptographic signature). |
| Page number | Current-page / total-page tokens that resolve at render time. |
| Page break | Forces the following content onto a new page. |
| Container | What it does |
|---|---|
| Row | The fundamental horizontal band. Holds columns; carries background, borders, spacing, conditions and loops. |
| Columns | Vertical slices inside a row. Set each column’s width as a % and drop content inside. |
| Row group / Section | Groups several rows together inside a column — optionally kept together on one page. |
| Loop | Repeats a row, column or group once per item of an array in your data (e.g. invoice line items). |
Drag in a pre-built, styled block and edit it — no need to assemble everything by hand:
Select a text element and its Content box on the Text tab is a rich text editor: formatting for individual words, things that resolve when the PDF is made (dates, page numbers, your data), and — on Pro — conditions that decide what prints.
Two hints sit above the box and are worth taking literally: type @ to insert anything, and Tab or “Exit format” to get back out of a format you are standing in.
All of this is available on every plan. Each control works on the text you have selected — with the cursor sitting somewhere and nothing selected, most of them have nothing to act on.
| Font | Applies a family and weight to the selected words — the same library the element uses, minus any family your plan no longer includes. “Library default” puts the selection back on the element’s own font. Three families are shown for speed; “All fonts” opens the searchable list. |
| Size | Font size of the selection, in pt. Clear the box and the selection inherits the element’s size. |
| Colour | Text colour of the selection. The swatch follows the caret, so it shows the colour of the text you are standing in — a selection spanning two colours shows the one it starts in. |
| Underline · Strikethrough · Overline | The three line decorations, each a toggle. |
| Superscript · Subscript | Real x² / x₂, not a smaller font. |
| Uppercase · Lowercase · Capitalize | Changes how the selection prints without retyping it. Mutually exclusive: applying the active one removes it. |
| Bullet list · Numbered list | Turns the selected lines into a list. Enter inside a list makes the next item; Enter anywhere else is a line break, never a new paragraph. |
| Insert link | Link the selected words to a web address, an email, a phone number, or another section of the same document. You choose the link colour and whether it is underlined, because each PDF library has a different idea of both. |
| Fill line | An underlined blank of N characters for a printable form — 8, 16, 24, 40 or any length you type, in black, slate or a colour of your own. Inserted at the cursor; put the cursor in an existing one to change it. |
| Exit format | Appears only when the cursor sits inside a format. Steps it past the formatting so what you type next is plain. Tab does the same thing. |
| Expand editor | Opens the same editor as a large, resizable pad for longer passages. Same toolbar, same text. |
Ctrl+B does nothing. Weight is part of the typeface here, not a switch on top of it: to make a word bold you select it and pick the family’s Bold weight from the font picker. This is what the PDF libraries themselves do — they load “Montserrat Bold” as its own font — and asking one for the bold of a bold is an error, not a heavier line.@ menuType @ anywhere in the text and a menu opens at the cursor. Tokens and icons are free; the last three are part of dynamic data Pro.
| Tokens | The current page number, the total pages, today’s date, the current year, the time, and the document title. They resolve when the PDF is made, not when you type them, so a document printed next month prints next month’s date. |
| Icons | 51 inline icons — ticks, arrows, phone, calendar, currency and the rest — at 4–48pt, in a colour you pick. You can also paste your own SVG. The colour is baked in when it is inserted, so pick it first. |
| Variables | A value from your data, by the name you gave it in Data Binding. |
| Data keys | A value from your data by its path, e.g. customer.address.city. |
| Loop fields | A field of the current item, when the element sits inside a loop — $item.name, $item.price. |
Everything inserted this way becomes a chip — one object you can select, move or delete, rather than loose characters. A date or time chip takes any PHP date format; these are ready-made:
d M Yd/m/Ym/d/YY-m-dd.m.YF j, Yj F YD, d M Yl, d F Yl, F j, Yd Md/mM YF YYH:iH:i:sh:i Ah:i ag:i AThe date is read in the document’s timezone, not your computer’s — which can be a different day either side of midnight.
Rows and columns can be shown or hidden by a condition. The If button does the same for a few words, or a single value, inside a line of text.
Select the words — or click an @ chip — and press If.
Choose Show if… and write the condition, e.g. $status == 'paid'. Type $ for your data keys.
For the other case, select a different piece of text, press If again and choose Otherwise show this, pointing at the condition you just made.
The two halves are tied together by the condition, not by sitting next to each other — “Paid in full, thank you” and “Payment due on receipt” can be at opposite ends of the paragraph with ordinary words in between, and only the words you marked are affected. There is no “else if”: two outcomes is what a sentence wants, and more than that is a table.
Conditions can sit inside conditions, and a conditional piece can hold chips and formatting of its own. On the canvas every branch is shown, badged IF and ELSE in amber so you can see what is there; the preview and the PDF are where exactly one of them prints. If you delete the if half and leave the else, the else prints unconditionally.
A loop repeats a whole row per item. When you only want the items inside a sentence — “Tags: urgent, legal and finance” — use the inline list button instead. Point it at an array in your data, choose the field to print, the separator, an optional “and” before the last one, how many to show before “+3 more”, and what to print when the array is empty.
The 123 button formats a number as a plain number, a currency or a percentage: decimals, thousands grouping, the symbol and which side it sits on, and which convention the separators follow (1,234.56, 1.234,56 or 1 234,56). It works on a number you have typed, and on a bound value whose number only exists at render time.
Bound values, inline lists and conditions are part of the same Pro feature. If a document was written while the plan included them, it keeps them and goes on printing exactly as it did — per piece: what was there stays, anything added afterwards does not, and a piece you delete cannot be added back.
Where a piece is not kept, the words stay and the behaviour goes. A bound value prints the literal text it shows in the editor, and both halves of a condition print, one after the other. The document gets shorter in meaning, never in content — nothing is silently deleted from it.
Select any element, row or column to edit it in the properties panel. Page-wide settings and defaults live in Page settings.
On text & heading elements (and as page-wide defaults).
| Font family & variant | Pick a family from the font library, plus its weight and style variant. Uploading your own is not offered — see Fonts. |
| Size | Font size in pt, px or mm (auto-converts when you switch unit). |
| Colour | Text colour (hex or picker). |
| Align | Left / center / right. |
| Decoration & transform | Underline / overline / line-through; uppercase / lowercase / capitalize. |
| Line height & indent | Line spacing (0.5–5) and first-line indent (pt). |
Structure and spacing.
| Width / Height | Column width in %, height in pt or %. |
| Padding & Margin | Inner padding on all sides; top/bottom margin on rows. |
| Alignment | Vertical align of content (top/middle/bottom) and horizontal align of nested content. |
| Column gap & widths | Gap between columns, and manual per-column width presets. |
On rows, columns and elements.
| Width | Per-side (top/right/bottom/left) or all, in pt. |
| Style & colour | Solid / dashed / dotted, any colour. On rows and columns you can also override style or colour per side — e.g. a single coloured bottom rule. |
| Radius | Rounded corners — all or per-corner (pt). |
On text & headings — mPDF only.
| Text shadow | On text and H1–H6: offset X/Y, colour and opacity. Presets: Subtle / Hard / Deep / Emboss. |
| Engine support | Drawn by mPDF only; DomPDF and html2pdf have no text-shadow support and render the text flat. Works at any nesting depth, but has no blur — mPDF offsets a copy of the text. |
On rows, columns and elements.
| Colour | Solid fill on rows, columns and elements. |
| Image | Row background image, with repeat and position. |
| Gradient | Multi-stop linear gradient with an angle. |
Whole-document settings.
| Size & orientation | Seven page sizes — A3, A4, A5, A6, Letter, Legal and Tabloid — each in portrait or landscape. |
| Margins | Outer paper margins in mm / pt / px. |
| Header & footer | Optional repeating header/footer zones, hideable on chosen pages. |
| Min canvas size | Minimum working height/width for the canvas. |
A page-wide stamp.
| Text or image | Stamp text (with its own font/size/colour) or an uploaded image. |
| Position & angle | A 3×3 preset grid or manual X/Y %, plus rotation. |
| Opacity & tile | Transparency 1–100%, and optional tiling across the page. |
Per component-type options.
| Image size | Width/height in % , mm or px. |
| QR / barcode | Value, size (mm), colour, error-correction (QR), format & label (barcode), native vs image rendering. |
| Blank | Blank line length. |
| Divider | Colour / thickness / style / spacing; line type (single, double, thin-thick); length as a % of the column with left / centre / right alignment; a label or ornament set into the line, with its own font, size, colour and weight; or flipped vertical with a set height. |
| Divider caveats | html2pdf draws dashed rules by filling one small shape per dash, so a long dashed rule makes a bigger file than a solid one. It has no round dots of its own, so a dotted rule is drawn there as a picture of them — except where its colour, thickness or style is a condition in exported code, which keeps html2pdf's small square dots. A vertical rule is a filled bar on all engines, so it is always solid. |
Every project can use the bundled fonts out of the box. The default typeface is DejaVu Sans, chosen because it covers Unicode symbols (arrows, stars, accents) reliably across all three libraries.
A curated library of typefaces, on the Fonts page, with their weights and styles already organised into families. You cannot upload your own — every family here is one we chose and hold a licence for, which is what lets us promise the next part: the fonts you use are bundled into your export, along with their licence, so the PDFs you generate and the code you hand on both carry the typeface legitimately.
@font-face for Dompdf, or native font data for mPDF. You don't manage any of that yourself.One template can produce unlimited documents by pulling in your data at render time.
On export these become {{ placeholders }} filled from a $data array you provide:
$html = file_get_contents(__DIR__ . '/template.php');
// Fill the {{ variables }} in your template with your own data
$data = [
'invoice_no' => 'INV-2043',
'client' => 'Acme Inc.',
'items' => [
['name' => 'Design work', 'price' => '$1,200.00'],
],
];
ob_start();
(function ($t, $data) { eval('?>' . $t); })($html, $data);
$html = ob_get_clean();Click Get Code, choose your engine, and download the bundle. It contains:
template.php — your layout as HTML with {{ variables }}.generate.php — a ready-to-run script that fills your data and renders the PDF.assets/ and fonts/ — images and any custom fonts your template uses.Keep the files together, install the library with Composer, drop your data into generate.php, and run php generate.php.
All three libraries take the same design and produce a PDF — but they differ in what they support natively. getpdfcode automatically applies the right technique for your chosen engine, so most of this is handled for you. This table tells you what to expect and where a feature has limits.
Every capability we have checked is here, for all three, with the catch spelled out wherever there is one — and where the three are equal, it says so. Each line was checked against what the converter hands each engine and, where it mattered, against the PDF that comes out, rather than copied from the libraries' own documentation. Where a note says something is resized, converted or worked out before export, getpdfcode does that for you.
Nativethe library does it itselfYesfully supportedCaveatworks, with a catchCannotit cannot
| Capability | html2pdf | Dompdf | mPDF |
|---|---|---|---|
| Codes | |||
| QR codes | NativeDrawn natively by TCPDF as vector art — sharp at any zoom, and no image to embed. | CaveatNo native QR, so it arrives as an SVG, which Dompdf draws as vector paths: sharp at any zoom, and it scans and prints correctly. The library simply does not generate the code itself. | NativeDrawn natively; the exported project adds mpdf/qrcode for it. One exception: ask for a transparent background and it falls back to an image, because mPDF paints an opaque white ground that no CSS can reach. |
| 1D barcodes (Code 128, EAN, UPC) | NativeNative 1D barcodes through TCPDF. | CaveatNo native barcodes: one arrives as an SVG, which Dompdf draws as vector paths rather than as a picture. | NativeNative 1D barcodes through mPDF’s own <barcode> tag. |
| 2D barcodes (PDF417, DataMatrix) | NativeThe only one of the three that draws PDF417 and DataMatrix itself. | CaveatArrives as an SVG, which Dompdf draws as vector paths. | CaveatmPDF’s <barcode> does not know these two, so they arrive as an SVG instead. |
| Language | |||
| Right-to-left text (Arabic, Hebrew) | CaveatRenders the characters, but joined scripts need careful font choice and the shaping is not as reliable. | CaveatDraws whatever glyphs the font carries and does no shaping, so joined scripts come out unjoined. | NativeThe best of the three by a wide margin — it does the bidi reordering and the letter joining for you. |
| Indic, Thai or CJK text | CaveatWorks with a font that carries the glyphs; the setup is fussier. | CaveatNeeds a font carrying the glyphs, and does no reordering for Indic marks. | NativeHandles the complex-script positioning these need. |
| Security | |||
| Password protection | NativeAES-256 wherever PHP has OpenSSL, and RC4-128 where it does not. | CaveatRC4 40-bit only. It keeps honest people out; it is not real encryption by modern standards. | CaveatRC4-128 — better than Dompdf, well short of AES. |
| Watermark on every page | YesSupported — the watermark is rasterised once and reused on every page. | YesSupported. | YesSupported. |
| Links and navigation | |||
| PDF outline (the bookmarks sidebar) | NativeNative bookmarks, nested to whatever depth you set. | CannotDompdf has no bookmark API at all, so the outline is dropped from the export. The document is fine; it simply has no sidebar. | NativeNative bookmarks, and they survive being inside a table — which the layout always is. |
| Internal links between sections | NativeJumps to the element you linked to. | CaveatThe jump lands on the right page but not on the element — Dompdf hardcodes a whole-page view for every destination. | NativeJumps to the element you linked to. |
| Clickable web, mail and phone links | NativeClickable, and your colour and underline are kept rather than forced to default blue. | NativeClickable, with your own colour and underline. | NativeClickable, with your own colour and underline. tel: links are rewritten on the way out, because mPDF treats any href without a dot as an internal jump. |
| Pictures and backgrounds | |||
| Photos and logos | YesFit, position and sizing all behave. | YesFit, position and sizing all behave. | YesFit, position and sizing all behave. |
| Backgrounds that cover an area | CaveatTCPDF has no background-size whatsoever, so the image is pre-scaled to the row for you before it is handed over. The output matches; the export carries a resized image. | NativeHonours background-size, so cover and contain simply work. | NativeHonours background-size on a row. |
| Tiled or positioned background patterns | CaveatRepeat and position work, but an axis that tiles ignores its position, and a bare "top" or "bottom" is read as left-centre. | YesRepeat and position both behave. | YesRepeat and position both behave. |
| Background colours | YesSupported. | YesSupported. | YesSupported. |
| Gradient backgrounds | YesNone of the three draws a CSS gradient, so it is rasterised to an image before export. TCPDF cannot stretch a background, so the image is drawn at the row’s size. | YesRasterised to an image before export and stretched to fill the row. | YesRasterised to an image before export and stretched to fill the row. |
| SVG shapes and icons | YesRasterised to PNG in the browser before export — PHP has no SVG renderer, and handing the markup straight to the three gave three different pictures. | YesSame rasterised PNG, so it looks identical to the other two. | YesSame rasterised PNG, so it looks identical to the other two. |
| Styling | |||
| Rounded corners on cards and rows | NativeThe only one with no catch here. Fill and border both round, on rows and on columns, at any nesting depth, with per-corner radii and either border-collapse mode. | CaveatRounds the background fill, but strokes the border with square corners whenever that cell’s table is border-collapse: collapse — which is what a column with its own height inside a fixed-height row gets, and what the Border Collapse control sets. A row radius is unaffected: it rides the wrapping <div>. | CaveatRounds a block <div> only, never a <td>, so a column’s rounded box is baked into an SVG background to get there. A nested row rounds only when it has an explicit height — without one it falls back to a square border — and per-corner radii or per-side borders fall back to square too. |
| Dashed or dotted borders | CaveatDraws both, correctly, on cells and on blocks — but by filling one small shape per dash rather than by setting a dash pattern, so the file grows with every dashed edge. Measured on a 120-cell table: 13.7KB solid, 41.8KB dashed, 99.1KB dotted, while the other two stay flat whatever the style. Render time is unaffected. Worth knowing before you put a dotted border on every cell of a long table. | NativeDraws a real dash pattern. | NativeDraws a real dash pattern. |
| Modern CSS colours — oklch(), hsl() | CannotTCPDF understands hex and rgb() and nothing else — a modern colour function is dropped, and the element renders with no colour at all. | NativeParses the modern colour syntaxes. | NativeParses the modern colour syntaxes. |
| Text shadow | CannotNo text-shadow — the text renders flat. | CannotNo text-shadow — the text renders flat. | CaveatThe only one with text-shadow, and it works at any depth. The offset renders; the blur radius is parsed and then ignored, so a blur-only shadow is invisible. |
| Letter and word spacing | CannotTCPDF has no equivalent and silently ignores both, so the declarations are left out rather than shipped dead. | NativeHonoured, including inside a table cell. | NativeHonoured, including inside a table cell. |
| First-line text indent | YesSupported. | YesSupported. | CaveatIgnored inside a table cell — which every row is — so the first line is pushed in with an invisible spacer instead. An indent that depends on a condition is only known when the document renders, so that one is not applied. |
| Library fonts, with bold and italic | NativeEach variant is registered as its own family, so bold and italic land on the real file instead of being synthesised. | NativeFont bytes are inlined into the document as data: URIs — the simplest of the three to move to another machine. | NativeEach variant registered as its own family, same as the other two. |
| Layout | |||
| Deeply nested tables inside columns | CaveatTCPDF compounds a percentage-width error at every level of nesting — about 216pt of drift six levels down — so nested columns are given point widths instead. It holds up, but it is the fragile one here. | NativeThe most predictable box model of the three, and the steadiest at depth. | NativeThe broadest HTML and CSS support at depth. |
| Boxes sized as a percentage of the page | NativeThe only one that resolves percentage heights itself. | CaveatCannot resolve them, so the percentage is worked out against the declared page box before export and handed over as a length. | CaveatCannot resolve them, so the percentage is worked out before export, exactly as for Dompdf. |
| Column widths in percent | CaveatExact at the top level. A table deeper down drifts — see nested tables above — so nested columns are handed over in points. | CaveatAdds a cell’s border on top of its percentage, so a bordered row overflows. Widths are converted to points wherever the container’s width is known. | CaveatIgnores percentage widths in a nested table and sizes the columns by their content instead, so widths are converted to points wherever the container’s width is known. |
| Left and right margins | CaveatA side margin moves a box without narrowing it, so the box overflows its cell. Left and right margins are turned into the cell’s padding instead, which looks the same. | YesSupported. | YesSupported. |
| Pages | |||
| A header and footer that repeat | YesSupported. | YesSupported. | YesSupported. |
| Hiding the header or footer on chosen pages | NativeTakes the page list as an attribute and does the rest itself. | YesNo equivalent of its own, so the list is applied against the pages it ends up producing. Same result. | YesNo equivalent of its own, so the band is pruned per page. Same result. |
| Page numbers and totals | YesSupported. | YesSupported. | YesSupported. |
Draws the most itself: native QR codes and 1D and 2D barcodes, AES-256 encryption, and rounded corners with no catch. The slowest of the three, and the fragile one when tables nest deep — nested columns get point widths to hold it steady, and side margins become padding.
Pure PHP with the most predictable CSS 2.1 box model — the steadiest of the three at depth — and the simplest fonts to move. Weakest encryption (RC4 40-bit), no bookmarks, and it generates no codes itself: a QR or barcode arrives as an SVG, which it draws as vector paths.
Broadest HTML and CSS support, the best Unicode, native QR and 1D barcodes, and the only text shadow. The fastest on a long document, but it uses the most memory; 2D barcodes arrive as an SVG instead.
Every export is plain PHP with no dependency on getpdfcode. Install the library and run it.
composer require spipu/html2pdf
require __DIR__ . '/vendor/autoload.php';
use Spipu\Html2Pdf\Html2Pdf;
$html = file_get_contents(__DIR__ . '/template.php');
// Fill the {{ variables }} in your template with your own data
$data = [
'invoice_no' => 'INV-2043',
'client' => 'Acme Inc.',
'items' => [
['name' => 'Design work', 'price' => '$1,200.00'],
],
];
ob_start();
(function ($t, $data) { eval('?>' . $t); })($html, $data);
$html = ob_get_clean();
$pdf = new Html2Pdf('P', 'A4', 'en');
$pdf->writeHTML($html);
$pdf->output('document.pdf');composer require dompdf/dompdf
require __DIR__ . '/vendor/autoload.php';
use Dompdf\Dompdf;
use Dompdf\Options;
// ...fill $html from template.php + your $data (see above)...
$options = new Options();
$options->set('isRemoteEnabled', true); // allow images
$dompdf = new Dompdf($options);
$dompdf->loadHtml($html);
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();
$dompdf->stream('document.pdf', ['Attachment' => false]);composer require mpdf/mpdf
require __DIR__ . '/vendor/autoload.php';
use Mpdf\Mpdf;
// ...fill $html from template.php + your $data (see above)...
$mpdf = new Mpdf(['format' => 'A4']);
$mpdf->WriteHTML($html);
$mpdf->Output('document.pdf', \Mpdf\Output\Destination::INLINE);generate.php we export is already pre-filled for your chosen engine (fonts, protection, page setup and all) — these snippets just show the shape.Free is not a trial: it keeps the whole builder and every base block. Clean, runnable PHP for html2pdf, Dompdf and mPDF — every library on every plan, unlimited. See pricing for the full Free vs Pro breakdown, or contact us with any question.