insert CSS file into FPDF

Asked

Viewed 269 times

1

I got the following code:

$estiloSite = file_get_contents('http://localhost/wesleyanagceu.com.br/_scripts/_css/style.css');
$estiloAdmin = file_get_contents('http://localhost/wesleyanagceu.com.br/_scripts/_css/admin.css');

require_once "_classes/_util/_PDF/PDF.php";

$html = $_POST["htmlPDF"];

$pdf = new PDF;
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->WriteHTML( $estiloSite, "_classes/_util/_PDF::HEADER_CSS");
$pdf->WriteHTML( $estiloAdmin, "_classes/_util/_PDF::HEADER_CSS");
$pdf->WriteHTML( utf8_decode ( $html ) );
$pdf->Output("relatorio.pdf","D");

I’m not finding it in the documentation of FPDF how is it done that in mPDF that’s how:

$stylesheet = file_get_contents('style.css');
$mpdf->WriteHTML($stylesheet,\Mpdf\HTMLParserMode::HEADER_CSS);

The way above works on mPFD.

How would it be in the FPDF knowing that it served as groundwork for creating of mPF?

1 answer

2

As far as I could check the FPDF doesn’t have this function, it doesn’t handle CSS very well, it has some plugins that deal with inline style, but it’s not much. This function is one of the things that the mPDF added. I recommend you use it or the HTML2PDF.

  • The FPDF are only 2 files, already mPDF... That’s why I’m giving preference to PPDF. But if there is no other way...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.