Security, Tech & Programming
Best PHP PDF Library without composer

Best PHP PDF Library without composer

You can use the pdf library DomPDF without using composer. Actually the library installation dues support composer too, but they provide normal releases on their official github repo which does not require composer.

How to install DOMPDF without composer

Simply goto:

Then goto releases and download the latest release.

Unzip the downloaded files in your projects subfolder, then point to the autoload file inside of it. Your basic hello world code with dompdf would look like this:

require_once 'dompdf/';

// reference the Dompdf namespace
use Dompdf\Dompdf;

// instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->loadHtml('hello world');

// Render the HTML as PDF

// Output the generated PDF to Browser

Once you get the hello world example working, then you can pass in your custom html to the loadHtml method of dompdf to print that as the pdf file.

How to give name to pdf file in dompdf

To give custom name to the generated pdf file, simply pass in the filename to the stream method instead of leaving it blank.

So the code will look like this:


Does DomPDF support flex and grid?

No. Dompdf does not support flex or grid.

Leave a Reply

Your email address will not be published. Required fields are marked *

Hire Me!