0
Good evening, everyone.
I am using summernote to create/manage texts, and Gero pdf using the MPDF library. However the alignments, (left, center and right), when used from the cells of a table, are not passed pro MPDF, while in HTML, or even on the print screen works perfectly.
A simple example of a table
<tbody>
<tr>
<td><p><span >CPF/CNPJ</span></p>
<p style="text-align: center; "><span style="font-size: 12px;">123.123.123-12</span></p>
</td>
<td>
<p><span style="font-size: 14px;">RG/Insc.Estadual</span></p>
<p style="text-align: center; "><span style="font-size: 12px;">123456789</span></p>
</td>
</tr>
</tbody>
In this case, in HTML ta cool, in PDF it is all aligned to the left.
I found on the MPDF site that is a limitation, where block tags (div, p, etc) are not accepted.
Tables
Block elements (e.g. DIV or P) are not supported inside tables. The content is displayed, but any CSS properties which apply to block elements are ignored (e.g. borders, padding, margins etc).
I tried to replace the tags, by span, with jquery but these also do not accept alignment.
tdtag = document.querySelectorAll("td");
tdtag.forEach( e => {
if(e.style.textAlign == "right"){
$(e).html("<span style='text-align:right'>"+$(e).html()+"</span>");
}
});
Someone’s been through this and there’s a solution to it?
span
is an element inline, so it has no larger width than its content, and with that alignment it has no effect. I do not know will work but try to change the properties of span with<span style='text-align:right; display: inline-block; width: 100%;'>
– Sam
Thanks for the tip. But even though it didn’t work, I imagine the MPDF always ignore an element that turns
block
oninline-block
within a table. I am trying to force the alignment by<td>
to see if it works– Rafael