harunB10
harunB10

Reputation: 5207

Wkhtmltopdf ignores Bootstrap table

I have a page with PDF export option. Beside these tables I have also three charts (Highcharts). These charts are exported fine but the table is completely ignored. Is there a way to fix this?

This is my code:

$pdf->setOption('enable-javascript', true);
$pdf->setOption('javascript-delay', 10000);
$pdf->setOption('no-stop-slow-scripts', true);
$pdf->setOption('dpi', 100);
$pdf->setOption('image-quality', 100);

return $pdf->setOrientation('landscape')->setOption('margin-top', 0)->download('export-' . $id . ' .pdf');

And simple bootstrap table: <table cellspacing="0" class="table table-responsive table-striped table-bordered">

Upvotes: 2

Views: 3151

Answers (2)

Niran Manandhar
Niran Manandhar

Reputation: 1107

changing the dpi worked for me. wkhtmltopdf -O Portrait --dpi 600 -L 0mm -R 0mm -T 0mm -B 0mm --page-size A4

Upvotes: 2

Alexander Reznikov
Alexander Reznikov

Reputation: 1268

If you want to use bootstrap styles in your PDF, then you should probably include bootstrap CSS file into your HTML-to-PDF code.

For example, like this:

<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TITLE OF YOUR PAGE</title>

<!-- include bootstrap CSS from CDN -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

...

I'm using snappy as wrapper for Wkhtmltopdf, but I'm sure that the common rule is the same: if you want to use some CSS, then you should include this CSS in your HTML code, which will be converted into PDF.

Upvotes: 1

Related Questions