Use case

Automate contract and
agreement PDF generation

Generate professional contract PDFs from HTML templates. Consistent formatting, custom fonts, and page numbering on every request, at any scale.

Start free

From template to signed PDF

Keep your contract logic in HTML. It's versioned, testable, and editable by anyone. Render to a string, POST to the API, stream the bytes to the client or store in S3.

PHP: generate a contract PDF from a template
<?php

use HtmlToPdfApi\HtmlToPdf;

class ContractService
{
    public function generate(Contract $contract): string
    {
        $html = view('contracts.template', ['contract' => $contract])->render();

        $sdk = new HtmlToPdf(['api_key' => config('services.htmltopdfapi.key')]);

        return $sdk->html($html)
            ->paperSize('a4')
            ->orientation('portrait')
            ->margins(top: 40, right: 32, bottom: 40, left: 32)
            ->footer('<div style="font-size:8px;color:#999;text-align:center;padding:4px 0">
                          Page <span class="pageNumber"></span> of <span class="totalPages"></span>
                          &nbsp;·&nbsp; Contract #' . $contract->reference . '
                      </div>')
            ->generate()
            ->content();
    }
}

Features for legal documents

Page numbering and total pages
Custom headers with contract reference
Consistent fonts across environments
A4 and Letter paper sizes
Precise margin control (mm)
Modern CSS for multi-column layouts
Works in any language via REST

Start generating contract PDFs free

200 pages/day on the free tier. No credit card required.

Get your free API key