Styling your PDF with CSS

An Easy to Use Course

Using mPDF and HTML means we can add CSS (Cascading Style Sheets) to format the colour, layout, fonts and more of the PDF output. In this example we add CSS within the HTML code to format the HTML tags. In subsequent examples we will use CSS stored in an external .css file to make the formatting more modular and reusable. View the code of the sample web page
View the PDF
        $html = '
        h1, h2, h3, p {
            font-family: Arial;
        p {
            font-family: Arial;
        <h1>About Tidalfire</h1>
        <p>Tidalfire provides PDF business tools and services for desktop, 
        web and mobile.</p>
        <h2>PDF Forms</h2>
        <p>Let your business benefit from dynamic PDF forms. 
        Mobile or desktop – convert your paper forms to intelligent, 
        customer friendly documents.</p>
        <h2>PDF Studio</h2>
        <p>PDF Studio™ an all-in-one, easy to use PDF editor 
        that provides all the features needed at a fraction of the cost of 
        Adobe® Acrobat® and other editors.</p>
        <h2>PDF Automation Server</h2>
        <p>PDF Automation Server (PAS) automates the receiving, processing 
        and routing of documents helping to streamline your 
        document workflows.</p>
        <h3>Contact Details</h3>
        require_once __DIR__ . '../../../../../mpdf7/vendor/autoload.php';
        $mpdf = new \Mpdf\Mpdf();

All code on this site can be used without warranty.

Copyright © 2019