2

How to create a single page pdf from a html file

I'm currently using the convert-html-to-pdf library (version: 1.0.1) to convert html files into pdf. But, the conversion is separating my html in multiple pages and it ends up breaking the code (streched divs).

Since my html file is responsive to certain needs, the size of the div blocks change on each file, and because of this I'm not able to determine when to "break" each page unless I somehow measure the size of the page and the size of the blocks. There are two possible corrections:

  • create a single page pdf (this one is preferred)
  • mesaure the size of the page and compare with the items to make sure they are not separeted each page

The first one is supposed to be easier, but I can't find anything in the documentation that helps me do that.

I'm inclined to accept libraries suggestions to create a single page pdf.

  • 1
    There are several solutions called that. Can you link which library? Tagging the programming language will help as well. Thanks! – Peter Krebs Nov 26 '21 at 14:59
  • [Here](https://github.com/alextiley/convert-html-to-pdf) is the link to the library I'm using. Also, I'm using typescript to write the code. – Helena Guimarães Nov 26 '21 at 15:05
  • 1
    Okay, nice. But I meant update your question. Others want to know too, without reading all the comments. – Peter Krebs Nov 26 '21 at 15:08
  • Mmhm. The repository does not mention tables or splitting pages. Maybe open an issue over at GitHub? If you are willing to switch to another library there are plenty of them. I liked [jsPDF](https://parall.ax/products/jspdf) – Peter Krebs Nov 26 '21 at 15:13
  • Do you know any libraries where I can configure height to be unlimited? My project really needs to have sort a "responsive height" depending on what the user selects to add on the pdf file. – Helena Guimarães Nov 29 '21 at 18:24

0 Answers0