html2pdf
html2pdf copied to clipboard
How can I prevent the width overflowing?
I use this tool to print differents reports on my system. Those are with dynamic content obviouslly, so I can't set a fixed width per table column. I tried setting a width as style on the table and didn't helped, tried setting a parent div over the table with fixed witdh and either worked. The problem happens when a column content is too large, the ideal solution is resolving it with linebreak, i dont care the height, but I need the width to fit
This is the report on the system.
This is the report on pdf.
Hi, I have a same problem. Html2Pdf is very useful library and I using it in my GLPI plugin, but there is no word-break or table width support which makes this overflowing problems. This issue was reported few times but unfortunately rejected. @spipu please consider implement word-breaking again. Regards, Mateusz
Hi Mateusnitka. On your code you can implement a some word wrapping function simple like this
function strWrap(&$cadena, $intLong = 50){
$intLen = 0;
$cadIzq = "";
$intLen = strlen($cadena) - 1;
$cadIzq = "";
$j = 0;
for ($i=0; $i<=$intLen; $i++){
$j = $j + 1;
$cadIzq = $cadIzq . $cadena[$i];
if(($cadena[$i] == " " or $cadena[$i] == "." or $cadena[$i] == ",") and $j >= $intLong) {
$cadIzq = $cadIzq . "<br />";
$j = 0;
}
}
$cadena = $cadIzq;
}
And call on your php like this
$strContenidoCampo = $ArrHdr002['lsver_value'];
strWrap($strContenidoCampo, 30);
I hope this can solve your issue.
@Urc0m thanks for reply. I will check your solution soon.
Regards, Mateusz
No table width support guys ? Really ?
I'm running through the same problems.
Don't you have some something lighter than adding some <br/>
with php ?
I can also add empty tabels same issue, overflowing when above 15 cells.