Search code examples
phppdfdompdf

How to export PDF from page.html with css DomPDF


actually i'm using domPDF to print pages into PDFs the issue is all the PDF i've print from externe pages ,has no CSS

this an exemple :

<?php

require __DIR__ . '/vendor/autoload.php';

use Dompdf\Dompdf;

$dompdf = new Dompdf();
$html = file_get_contents('page.html');

$dompdf->loadHtml($html);

$dompdf->setPaper('A4', 'landscape');

$dompdf->render();

$dompdf->stream();

The page.html has links of bootstrap

enter image description here

Question :

How to add external url with their css ? I do not know if this is even possible. Thanks for the help ;)


Solution

  • so the solution is quite simply, the domPDF vs TCPDF or FPDF is using their own styling, so css is not recognized in domPDF you have to design your own styling using domPDF functions

    for line color :

    $this->SetFillColor(218,218,218);
    

    For text color :

    $this->SetTextColor(255,255,255);