WKhtmltopdf renders pdf different than html page

3.1k views Asked by At

I have a simple webpage, using bootstrap for css. I want to export the page to pdf, using wkhtmltopdf, but some css styles are completely ignored, but others not.

Here's my code:

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link href='file:///C:/Users/luna/Desktop/pdftemp/css/bootstrap.css' rel="stylesheet">
  <title>
     PDF Template
  </title>
</head>
<body>
  <div class="panel panel-success">
    <div class="panel-heading">
      <h4 class="panel-title">Basic Details</h4>
    </div>
  <div class="panel-body">
     <div style="margin-right: -15px; margin-left: -15px;">
        <div class="col-lg-4">          
            Experiment Name: <br> 
            TestExp 
            Date: <br>
            24.05.2015  
        </div>
        <div class="col-lg-4">      
           Experiment Name: <br> 
           Test<br>
           Date: <br>
            24.05.2015
        </div>
    </div>      
 </div>
</body>

Browser View: Browser Output

PDF:

PDF Output

I want to achieve, that the pdf is same like the browser output. What am I doing wrong ?

1

There are 1 answers

0
Sunil Singh On

You need to change view port size -

Setting page.viewportSize = { width: 1280, height: 1024 } results in a "what is my screen resolution" of 1280 x 800.