DomPDF (Fast PDF Outputs)

The artiframe add dompdf command installs the famous dompdf/dompdf library, which converts simple and clean HTML/CSS structures into PDFs at incredible speeds. It is more lightweight than mPDF but adheres closer to CSS3 rendering standards.

💡 Information: Direct Usage
ArtiFrame does not copy a specific integration (Wrapper/Stub) class to the src/Service folder for this package. The installation simply includes the package into the project via Composer. The codes below are basic usage examples demonstrating the package's native operations. For more information, please review the DomPDF Repository.
Installation
terminal
$ artiframe add dompdf
Usage Example

Unlike mPDF, DomPDF processes the page through a render operation first, and then streams it to the browser.

ReportController.php
<?php

use Dompdf\Dompdf;
use Dompdf\Options;

// 1. Define Options (e.g., Output quality, allow remote images)
$options = new Options();
$options->set('isRemoteEnabled', true); // Allows downloading images starting with http://

// 2. Initialize the Object
$dompdf = new Dompdf($options);

// 3. HTML Content
$html = '
    <style>
        body { font-family: sans-serif; color: #333; }
        h1 { color: #d32f2f; }
    </style>
    <h1>Sales Report</h1>
    <p>This report was generated on <b>'.date('Y-m-d').'</b>.</p>
';

$dompdf->loadHtml($html);

// 4. (Optional) Set paper size and orientation (portrait / landscape)
$dompdf->setPaper('A4', 'portrait');

// 5. Render the HTML into PDF memory
$dompdf->render();

// 6. Send to Browser
// Attachment => 0: Opens in browser, Attachment => 1: Forces download
$dompdf->stream("sales-report.pdf", ["Attachment" => 0]);