How to apply bootstrap style in dompdf

MayuriS picture MayuriS · May 1, 2015 · Viewed 27.4k times · Source

I'm using bootstrap grid to display and i want that my client download it in pdf so for that i'm using dompdf but dompdf is not able to apply bootstrap style. I cannot go back and turn my bootstrap grid to basic html tables and using different plugin to convert to pdf i found them difficult and time consuming(especially in installing composer and then updating i'm new ) is there any way out so that i can easily apply bootstrap style to my pdf

   $pr_dt=$_POST['hid'];//div elements which i want ot convert them to pdf and also contain bootstap lib link
   include_once("../assets/converter/dompdf/dompdf_config.inc.php");
   $dompdf =  new DOMPDF();
   $dompdf->load_html($pr_dt);
   $dompdf->render();
   $dompdf->stream("MRA.pdf");

or at least is there any online converter for bootstrap grid to html tables

Answer

alan0xd7 picture alan0xd7 · May 1, 2015

You need to make sure dompdf can find your CSS files. You can do this with set_base_path, for example:

$dompdf->set_base_path("/www/public/css/");

You also need a to specify the CSS file, something like:

<html>
  <head>
    <link type="text/css" href="style.css" rel="stylesheet" />
  </head>
<body>
...