Pdfkit呈现的HTML与浏览器的呈现方式不同

时间:2019-11-20 12:52:14

标签: html css python-3.x pdf pdfkit

我在htmlstring以下:

<!DOCTYPE html>
<html>
   <body>
      <div  style="float:left;">
         <table>
                    <tr>
                      <th>Commands</th>
                    </tr>
                    <tr>
                      <td>Jill</td>
                    </tr>
                    <tr>
                      <td>Eve</td>
                    </tr>
                    <tr>
                      <td>John</td>
                    </tr>
                    <tr>
                      <td>John</td>
                    </tr>
                    <tr>
                      <td>John</td>
                    </tr>
                    <tr>
                      <td>John</td>
                    </tr>
                    <tr>
                      <td>John</td>
                    </tr>
                    <tr>
                      <td>John</td>
                    </tr>
                    <tr>
                      <td>John</td>
                    </tr>
                    <tr>
                      <td>John</td>
                    </tr>
                    <tr>
                      <td>John</td>
                    </tr>
                    <tr>
                      <td>John</td>
                    </tr>
                    <tr>
                      <td>John</td>
                    </tr>
                    <tr>
                      <td>John</td>
                    </tr>
         </table>
      </div>
      <div  style="float:left;">
         <img src='pathToImag' >
      </div>
  </body>
</html>

它在浏览器中并排显示我的表和图像。但是,当我使用pdfkit创建pdf时,它将在表格下方显示图像。

import pdfkit

config = pdfkit.configuration(wkhtmltopdf=path_wkhtmltopdf)
pdfkit.from_string(htmlString, pdffilename, configuration=config)

如何解决此问题? 有没有更好的方法并排显示div元素?  我希望两个div元素在pdf中并排。

0 个答案:

没有答案