Closed codeservice closed 7 months ago
line-height
in PDFMake doesn't work like in HTML/CSS. I'd recommand to use a number value only instead of a number + "px/%" (e.g. line-height:1.2
), and to do some test in the PDFMake playground to find which value would work best with your expectation. In your case, the use of line-height
is weird, and maybe a padding/margin would be good enough?!
Also your HTML code is messy and has too many layers of unnecessary tags, that may cause an unexpected result. The translation of the HTML to PDFMake is very complex, and this tool is only here for simple code and quick page layout.
Try to simplify your HTML code. For example:
<div id='element-to-print'>
<div style="color: #2d2d2d;font-weight:bold;margin-top:5px;font-size:19.2px;">First sentence</div>
<ul>
<li>Option 1</li>
<li>Option 2</li>
<li>Option 3</li>
</ul>
<div style="color: #2d2d2d;font-weight:bold;margin-top:15px;font-size:19.2px;">Second sentence</div>
<ul>
<li>Option 4</li>
</ul>
</div>
And finally, be aware that <p>
adds by default a margin which could also impact the result.
Also your HTML code is messy and has too many layers of unnecessary tags,
Yes, this code generated by html WYSIWYG editor. Whoever using it doesn't understand html code well, but this code valid. I can't really tell them how to modify html for export optimization. Only solution for now is to disable line-height.
Yes, I think it's better to remove line-height
in your case :-)
Something wrong with line-height calculation: