Error when trying to display the number of pages in PdfKit

FelipeMedel

A few days ago, I started working with PDFKIT, to generate reports in Python. My problem appears when I want to show the number of pages that the document has. I do not know what I am missing, or where I am failing. Below is the error that is shown, the code that I am using, and the resulting pdf.

Error: The switch --footer-right, is not support using unpatched qt, and will be ignored

Code:

import pdfkit

options = {
    'page-size': 'Letter',
    'margin-top': '1cm',
    'margin-right': '1cm',
    'margin-bottom': '1cm',
    'margin-left': '1cm',
    '--footer-right': '[page]',
}
body = u"""
    <html>
        <head>
            <meta name="pdfkit-page-size" content="Letter"/>
            <meta name="pdfkit-orientation" content="Portrait"/>
            <meta charset="utf-8">
            <style>
                .td_left{
                    text-align: left;
                }
                .td_rigth{
                    text-align: right;
                }
                img{
                    width: 150px;
                    height: auto;
                    position: absolute;
                    top: 0;
                    left: 0;
                }
            </style>
        </head>
        <body>
            <img src='/home/produccion/Downloads/logo.png'>
            <center>
                <h2><b>NOMBRE DE LA EMPRESA - NOMBRE DE LA SUCURSAL</b></h2>
                <h3><b>NIT: 000.000.000-0</b></h3>
                <h2><b>CONTABILIZACIÓN</b></h2>
            <center>
            <table>
                <thead>
                    <th>CUENTA PUC</th>
                    <th>BOD</th>
                    <th class='td_left'>TERCERO</th>
                    <th class='td_rigth'>DOC N°</th>
                    <th class='td_rigth'>VENCE</th>
                    <th class='td_rigth'>CANTIDAD</th>
                    <th class='td_rigth'>DÉBITO</th>
                    <th class='td_rigth'>CRÉDITO</th>
                </thead>
                <tbody>
    """
for i in range(15):
    body += """<tr>
                    <td>0000-00-000</td>
                    <td>{0}</td>
                    <td class='td_left'>NOMBRE DEL TERCERO</td>
                    <td class='td_rigth'>AAA0000000001</td>
                    <td class='td_rigth'>01/01/2000</td>
                    <td class='td_rigth'>0.0</td>
                    <td class='td_rigth'>00000000</td>
                    <td class='td_rigth'>00000000</td>
                </tr>""".format(i+1)
body += """</tbody>
            </table>
        </body>
    </html>"""
pdfkit.from_string(body, 'ejemplo.pdf', options=options)  

Result:

image of the report

ekhumoro

The problem was that the installed version of wkhtmltopdf was 0.12.4, which did not have the patched qt. The solution was to uninstall this version and install version 0.12.3 (which does have the patched qt):

cd ~
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.3/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
tar vxf wkhtmltox-0.12.3_linux-generic-amd64.tar.xz 
cp wkhtmltox/bin/wk* /usr/local/bin/

And this can be confirmed with:

$ wkhtmltopdf --version
wkhtmltopdf 0.12.3 (with patched qt)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Error when trying to display image in tkinter canvas

Error when trying to display a timer into button text

Getting error when trying to display button

Error when trying to display page in JSON format

parse error when trying to display in laravel view

Getting an error when trying to display images

Attribute error when trying to get number of nodes

Error when trying to add a scaffolded item in Razor Pages

undefined index when trying to display number from database

How to fix an error when trying to display an error from the React server?

node PDFkit blank pages

Error 404 when trying to display images from custom folder in Wordpress

File storage error when trying to display an OpenStreetMap map

Error Appears When Trying to Display MySQL Table Data in HTML Table

Error when trying to display dataframe using renderDataTable in Shiny

How to resolve error when trying to open Windows Display Settings?

Getting 404error when trying to display a jsp

Error when trying to display ads - Android C# Xamarin

Django error when trying to display the sign up form

Error when trying to display an image saved in a computer file

object HTMLInputElement error when trying to display random task

Error display when trying to copy columns to a new workbook

Yolov4 error when trying to display image on custom model

404 Not Found Error when trying to display a chart with Chart.js

How to overcome a 403 error when trying to display an invoice?

Error when trying to get the value of an input number with JavaScript

Error 424 "Object Required" when trying to calculate the number of used rows

Getting error number -1700 when trying to mount a network drive

Display an error when user enters a number instead of a string