The code im using as follows
ob_start();
?>
<table cellspacing="0" cellpadding="1" border="1">
<tr>
<td align="center" rowspan="3"><br /><? echo "لا اله الا الله"; ?></td>
<td align="center" class="exclude">COL 2 - ROW 1</td>
<td align="center">COL 3 - ROW 1</td>
</tr>
<tr>
<td align="center" rowspan="2">COL 2 - ROW 2 - COLSPAN 2<br />text line<br />text line<br />text line<br />text line</td>
<td align="center">COL 3 - ROW 2</td>
</tr>
<tr>
<td align="center">COL 3 - ROW 3</td>
</tr>
</table>
<?
$tbl=ob_get_clean();
i want to exclude or filter some cells from the above code before send it for another processing
You can then create a style which will hide those cells for you.
ob_start();
?>
<style>
.exclude{display:none}
</style>
<table cellspacing="0" cellpadding="1" border="1">
...
Related
Just want to display html table with TCPDF but getting errors instead.
Here is my code:
$tbl = <<<EOD
<table cellspacing="0" cellpadding="1" border="1">
<tr>
<td >
aaaaa
</td>
<td colspan="2" rowspan="2" >
bbbb
</td>
</tr>
<td rowspan="2">
hhhhh
</td>
</tr>
<tr>
<td>
iiii
</td>
<td>
jjjj
</td>
</tr>
</table>
EOD;
But when I replace my html table code with following html table code (from TCPDF examples), it displays correctly:
$tbl = <<<EOD
<table cellspacing="0" cellpadding="1" border="1">
<tr>
<td rowspan="3">COL 1 - ROW 1<br />COLSPAN 3</td>
<td>COL 2 - ROW 1</td>
<td>COL 3 - ROW 1</td>
</tr>
<tr>
<td rowspan="2">COL 2 - ROW 2 - COLSPAN 2<br />text line<br />text line</td>
<td>COL 3 - ROW 2</td>
</tr>
<tr>
<td>COL 3 - ROW 3</td>
</tr>
</table>
EOD;
Could you please check my html table code and help me to find the mistake.
After the first <tr>, you have an extra </tr>, making the document invalid. Indented, your HTML is:
<table cellspacing="0" cellpadding="1" border="1">
<tr>
<td>aaaaa</td>
<td colspan="2" rowspan="2">bbbb</td>
</tr>
<td rowspan="2">hhhhh</td>
</tr>
<tr>
<td>iiii</td>
<td>jjjj</td>
</tr>
</table>
I'm using mpdf to generate PDF from a form. In form I have an option to adding new rows to table. The problem is when count of rows is too big for generated PDF page. Then the table is resizing (it's smaller) instead of going to the next page.
This is mpdf code:
$mpdf=new mPDF('UTF-8','A4','','',20,15,48,25,10,10);
$mpdf->WriteHTML(generatePDF());
$mpdf->Output();
exit;
This is html table code:
function getHTMLStyle(){
$html ='<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>
<tr>
<td >B</td>
<td ><b>'.$b.'</b><br /><br /> '.$_POST['organizationName'].'</td>
</tr>
<tr>
<td >C</td>
<td></td>
<table class="items2" width="100%" page-break-before="always" >
<tr>
<td ><b>'.$c.'</b></td>'.addTableC().'
</tr>
</table>
</tr>
This is image with property view:
And this is an amage with wrong view:
How can I make a break in table and continue to another side?
Because you're incorrectly nesting tables -
<tr>
<td >C</td>
<td></td>
<table class="items2" width="100%" page-break-before="always" >
<tr>
<td ><b>'.$c.'</b></td>'.addTableC().'
</tr>
</table>
</tr>
The table should be inside the <td> tag, like so:
<tr>
<td>C</td>
<td>
<table class="items2" width="100%" page-break-before="always" >
<tr>
<td ><b>'.$c.'</b></td>'.addTableC().'
</tr>
</table>
</td>
</tr>
I try to create tcpdf using writeHTML like this $pdf->writeHTML($html, true, 0, false, 0); which $html value like code below
<table border="1">
<tr>
<td width="100%" colspan="4">
<table border="0">
<tr>
<td width="18%" style="border-right:0.01px">Test 1</td>
<td width="12%">Test 2</td>
<td width="20%">Test 3</td>
</tr>
<tr>
<td width="18%" style="border-right:0.01px">Test 4</td>
<td width="12%">Test 5</td>
<td width="20%">Test 6</td>
</tr>
</table>
</td>
</tr>
</table>
style="border-right:0.01px" or style="border-right:0.1px" or style="border-right:1px" provide same result of border width, how to make this right border smaller? because my result rigth border on Test 1 and Test 4 are biggest then outside border.
If you're a little more explicit in your border definition it'll work as you expect. TCPDF's HTML/CSS parser is rather limited so it helps to be as specific as possible with your styling rules and the like.
Your code should work with either border-right-width: 0.1px or with the rest of CSS properties for the shorthand of border-right, see the example HTML below and accompanying screenshot of a rendered PDF (zoomed to highlight difference)
<table border="1">
<tr>
<td width="100%" colspan="4">
<table border="0">
<tr>
<!-- This should work -->
<td width="18%" style="border-right-width:0.1px;">Test 1</td>
<td width="12%">Test 2</td>
<td width="20%">Test 3</td>
</tr>
<tr>
<!-- As should this -->
<td width="18%" style="border-right:0.1px solid black;">Test 4</td>
<td width="12%">Test 5</td>
<td width="20%">Test 6</td>
</tr>
<tr>
<!-- However, this does not. -->
<td width="18%" style="border-right:0.1px">Test Broken</td>
<td width="12%">Test :)</td>
<td width="20%">Test :)</td>
</tr>
</table>
</td>
</tr>
</table>
As you can see, it handles the first two definitions as expected with thinner borders.
I use style="border-right-color:white" to hidden right border
<td style="border-right-color:white; border-bottom-color:black; border-top-color:black"></td>
i want to export this table to a variable
$tbl=<<<EOT
<table cellspacing="0" cellpadding="1" border="1">
<tr>
<td rowspan="3">$res=mysql_query($sql);<br />COLSPAN 3</td>
<td>COL 2 - ROW 1</td>
<td>COL 3 - ROW 1</td>
</tr>
<tr>
<td rowspan="2">COL 2 - ROW 2 - COLSPAN 2<br />text line<br />text line<br />text line<br />text line</td>
<td>COL 3 - ROW 2</td>
</tr>
<tr>
<td>COL 3 - ROW 3</td>
</tr>
</table>
EOT;
but the following code appeared as text !!
=mysql_query();
You can't use functions inside the EOT block.
You have to define a variable outside of it to use it inside the EOT block:
$res = mysql_query($sql);
$tbl=<<<EOT
<table cellspacing="0" cellpadding="1" border="1">
<tr>
<td rowspan="3">$res<br/>COLSPAN 3</td>
<td>COL 2 - ROW 1</td>
<td>COL 3 - ROW 1</td>
</tr>
<tr>
<td rowspan="2">COL 2 - ROW 2 - COLSPAN 2<br/>text line<br/>text line<br/>text line<br/>text line</td>
<td>COL 3 - ROW 2</td>
</tr>
<tr>
<td>COL 3 - ROW 3</td>
</tr>
</table>
EOT;
i have a huge table in my php page that contains alot of php coding inside it
i want to export it using tcpdf
the example in samples of thier website prints html as a variable and export it like that
$tbl = <<<EOD
<table cellspacing="0" cellpadding="1" border="1">
<tr>
<td rowspan="3">COL 1 - ROW 1<br />COLSPAN 3</td>
<td>COL 2 - ROW 1</td>
<td>COL 3 - ROW 1</td>
</tr>
<tr>
<td rowspan="2">COL 2 - ROW 2 - COLSPAN 2<br />text line<br />text line<br />text line<br />text line</td>
<td>COL 3 - ROW 2</td>
</tr>
<tr>
<td>COL 3 - ROW 3</td>
</tr>
</table>
EOD;
my table has many many sql and php coding ,,,,etc
any php code i put inside it not appeared on output
how to print it?
and here is my table i want to print
<table class="table" width="95%">
<tbody>
<tr >
<td width="20" class="tabletop">م</td>
<td class="tabletop" >name</td>
<td class="tabletop" style="width:120px">date</td>
<td class="tabletop" style="width:120px">note1</td>
<td class="tabletop" style="width:100px">note2</td>
<td class="tabletop" style="width:90px">note3</td>
</tr>
<? $res=mysql_query($sql);
while($resArr=mysql_fetch_array($res)){ ?>
<tr style="width:700px">
<td class="tabletext"><?= ++$serial;?></td>
<td class="tabletext" ><?= $resArr[stName];?></td>
<td class="tabletext"><?= $resArr['date'];?></td>
<td class="tabletext" ><?= $resArr[matName];?></td>
<td class="tabletext" ><? if($resArr[exam]==1) echo "work";else echo "final";?></td>
<td class="tabletext" ><? if($resArr[exam_type]==1) echo "prac";else echo "test";?></td>
</tr>
<? }?>
</tbody>
</table>
<?php
$print = '<table class="table" width="95%">
<tbody>
<tr >
<td width="20" class="tabletop">م</td>
<td class="tabletop" >name</td>
<td class="tabletop" style="width:120px">date</td>
<td class="tabletop" style="width:120px">note1</td>
<td class="tabletop" style="width:100px">note2</td>
<td class="tabletop" style="width:90px">note3</td>
</tr>';
$res = mysql_query($sql);
while ( $resArr = mysql_fetch_array($res) ){
$print .= '
<tr style="width:700px">
<td class="tabletext">'.$serial.'</td>
<td class="tabletext" >'.$resArr['stName'].'></td>
<td class="tabletext">'.$resArr['date'].'></td>
<td class="tabletext" >'.$resArr['matName'].'></td>
<td class="tabletext">';
if($resArr['exam']==1){
$print .= 'work';
}else{
$print .= 'final';
}
$print .= '</td><td class="tabletext" >';
if($resArr['exam_type']==1){
$print .= "prac";
}else{
$print .= "test";
}
$print .= '</td></tr>';
}
$print .= '</tbody></table>';
then simply use the variable $print