Relorer / HTMLToQPDF

HTMLToQPDF is an extension for QuestPDF that allows to generate PDF from HTML
MIT License
81 stars 28 forks source link

Empty paragraphs <p> not being displayed #24

Open mjefim opened 2 days ago

mjefim commented 2 days ago

Hi, I am trying to render html that contains empty paragraphs to provide some spacing in the text. The issue is that if the paragraphs are empty the output does not seem to contain them. I am attaching the test html and a screenshot of the output (please ignore the yellow masking, it just hides other information).

Image of the output: image

HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
      <style>
          body {  font-family:Calibri;
          }
          p {  margin-bottom: 15px;
          }
      </style>
  </head>
  <body>
    <p>Testing the empty paragraphs for spacing.</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>two empty paragraphs before this</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>three empty paragraphs before this</p>
  </body>
</html>
uladzimirvysotski commented 2 days ago

Hi, why empty paragraphs?

Maybe you should try something else, like <br> ?

mjefim commented 1 day ago

The HTML is the output of a WSIWYG editor, so I can not fully control the HTML in advance. I guess it could be possible to replace it the empty paragraph with the line break but I would rather keep the preprocessing to a minimum. Is there another solution perhaps?

uladzimirvysotski commented 1 day ago

You always can contribute :)