2

We need solution using wkhtmltopdf tool only as per our reqirement. We do not need to use any other tool to convert.

We are generating pdf file with wkhtmltopdf tool, and we are using latest version 0.12.6 (with patched qt). But generated pdf display cutting fonts at page end. Half fonts are display at the page end and another half fonts display at the next page start.

Please find HTML file from given link below.

https://github.com/vbthakkar9/internal-link/blob/main/TestFile.html

We are using wkhtmltopdf command to generate PDF as below

c:\Program Files\wkhtmltopdf\bin>wkhtmltopdf --print-media-type c:\Users\cpshah\Desktop\TestFile.html c:\Users\cpshah\Desktop\TestFile.pdf

We have already gone through all the solutions suggested in the Stack Overflow, but those solutions are not working in my case. We have also gone through the suggested SO link

avoid page break inside row of table

But it is not working in my case.

Please Note that when we create the pdf with "Save As Pdf" option (First open HTML in browser and then click CTRL + P, it opens print pages tool and then we do "Save As Pdf"), It will generate perfect replica of HTML i.e., perfect PDF.

We have already tried --print-media-type option with wkhtmltopdf and by applying CSS like below, but not works.

1)

@media print {
    table, tr, td, th, tbody, thead, tfoot {
        page-break-inside: avoid !important;
    }
}
@media print {
    table { page-break-inside:auto; page-break-after:auto }
    tr, td, div, span  { page-break-inside:avoid; page-break-after:auto } 
    thead { display:table-header-group }
    tfoot { display:table-footer-group }
}
@media print {
    thead {
        display: table-row-group;
    }
    tr {
        page-break-before: always;
        page-break-after: always;
        page-break-inside: avoid;
    }
    table {
        word-wrap: break-word;
    }
    table td {
        word-break: break-all;
    }
}

With or without above CSS, we are getting PDF font cutting pages like

Font Cutting - 1

enter image description here

Header Cutting - 2

enter image description here

We want exact replica of generated pdf by "Save As Pdf" option from browser.

Please let us know how we can achieve the same display and what we need to change. Thank you in advance.

Chirag Shah
  • 353
  • 1
  • 13

0 Answers0