1

I have tried to add css in mpdfstyletables.css file but can not able to add new css. PHP code:

<?php

$html = utf8_decode($html);
$html = iconv("UTF-8","UTF-8//IGNORE",$html);
include("./MPDF/mpdf.php");
$tpdf=new mPDF('c','A4','','',32,25,27,25,16,13); 
$tpdf->ignore_invalid_utf8 = true;
$stylesheet = file_get_contents('mpdfstyletables.css');
$tpdf->WriteHTML($stylesheet,1);
$tpdf->WriteHTML($html,2);
$tpdf->Output($fname,'I');
exit();
?>

I have tried this but not work for me.

How can I add css. I appreciate all response. Thanks Ahead.

2
  • What is in the css file? The code you posted should work correctly. Commented Sep 22, 2016 at 6:21
  • Wouldnt that fail because you are writing this to html without tags? Commented Sep 22, 2016 at 8:01

1 Answer 1

1

Can you try to render the html content instead of utf8_decode.

i.e,

 $tpdf->WriteHTML(("youtfilename.php")->render(),2);

By using like this I have applied two css files and it's working fine.

Hope it might help!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.