I have some form data and after submitting, a PDF is generated. The problem is size of tables in PDF. If some string in my form is too long the PDF is generated wrongly. It's because the tables. They have static size so if string is too long the table did not accommodate it. I use mPDF library.
How can I make this tables size dynamics so as to their size changed depending on the length of string?
If string {p} is longest then width of table the table size decrease. I want to if the string {p} is longest than width of table then {p} should writing out in next line and the height of table should increase.
A screenshot if string in field (name) is short:
A screenshot if string in field (name) is long:
A screenshot if string in field (name) is very long:
Here is a fragment of code with mPDF:
$mpdf=new mPDF('UTF-8','A4','','',20,15,48,25,10,10);
$mpdf->shrink_tables_to_fit=1;
$mpdf->keep_table_proportions = true;
$mpdf->WriteHTML(generatePDF());
$mpdf->AddPage();
$mpdf->WriteHTML(generatePDF2());
$mpdf->Output();
exit;
And fragment of HTML tables:
function generatePDF(){
global $a,$b,$c,$d;
$html = getHTMLStyle().'
<div style="text-align: left;"><span style="font-size: 11pt;font-weight: bold;">FORMULARZ KONSULTACJI<br />PROJEKTU PRAWA MIEJSCOWEGO<br /> W ZAKRESIE DZIAŁALNOŚCI STATUTOWEJ ORGANIZACJI POZARZĄDOWEJ*<br /><br /></span></div>
<table class="items" width="100%" style="font-size: 9pt; border-collapse: collapse;" cellpadding="8">
<tr>
<td width="5%">A</td>
<td width="95%"><b>'.$a.'</b><br /><br /> '.$_POST['title'].'</td>
</tr>
Here:
Try using a fixed value for table width instead of a percent. something like:
And see what happens.
It is really hard to find the problem, but the answer is simple. table with style="overflow:wrap" after reading the source code:
It's a late answer but it's worth of answering now. I too faced same problem when a table tr have very big content. I tried the below solution but no luck.
Then I have changed my html structure from table into div, boom it's worked. So now it's working perfectly and the big content is spiting properly between the pages without overlapping header and footer. I hope it will help someone. Cheers