Problem: Currently I have problem aligning the PDF that I am creating as it is different with normal CSS that I know.
Problem:
What I need it to be solve:
Make it align, for the image I provided, I wanted "No.SAG" below "Old"
This is the code:
<table class="unstyledTable">
<thead>
<tr>
<th>Name:</th>
<th>Test Data</th>
<th></th>
<th>Number card IC</th>
<th></th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<td>Name Agent::</td>
<td>TomHansom </td>
<td></td>
<td>New:</td>
<td>foot5</td>
<td></td>
</tr>
</tfoot>
<tbody>
<tr>
<td>Address:</td>
<td>werwrwrwwwwwwwwwwwwww wwwwwwwwwwwwwwwwwwww</td>
<td></td>
<td>Old:</td>
<td>cell5_1</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td>No.SAG:</td>
<td>cell5_2</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td>Number.Siri:</td>
<td>cell5_3</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
Might be easier to put both in columns as tables in a parent table. Check out my code below to see if this is what you were after.
<table class="unstyledTable">
<tbody>
<tr>
<td valign="top"><table>
<tbody>
<tr class="unstyledTable">
<th>Name:</th>
<th>Test Data</th>
</tr>
<tr class="unstyledTable">
<td>Address:</td>
<td>werwrwrwwwwwwwwwwwwww wwwwwwwwwwwwwwwwwwww</td>
</tr>
<tr class="unstyledTable">
<td></td>
<td></td>
</tr>
<tr class="unstyledTable">
<td></td>
<td></td>
</tr>
<tr class="unstyledTable">
<td></td>
<td></td>
</tr>
<tr class="unstyledTable">
<td>Name Agent::</td>
<td>TomHansom </td>
</tr>
</tbody>
</table></td>
<td valign="top"><table>
<tbody>
<tr class="unstyledTable">
<th>Number card IC</th>
<th></th>
</tr>
<tr class="unstyledTable">
<td>Old:</td>
<td>cell5_1</td>
</tr>
<tr class="unstyledTable">
<td>No.SAG:</td>
<td>cell5_2</td>
</tr>
<tr class="unstyledTable">
<td>Number.Siri:</td>
<td>cell5_3</td>
</tr>
<tr class="unstyledTable">
<td></td>
<td></td>
</tr>
<tr class="unstyledTable">
<td>New:</td>
<td>foot5</td>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table>
Related
I am using HTml2pdf library to convert HTML to PDF.
Below is the code i am using.
PHP
require __DIR__.'/vendor/autoload.php';
use Spipu\Html2Pdf\Html2Pdf;
$html2pdf = new Html2Pdf();
$html2pdf = new HTML2PDF('P', 'A4', 'en');
$html2pdf->setTestTdInOnePage(false);
$html = file_get_contents('index.html');
$html2pdf->writeHTML($html);
$html2pdf->output();
HTML
<div class="bap">
<div class="row">
<div class="par_col">
<div class="column">
<img src="b.jpg" alt="test">
<table style="width:99%" class="feetop">
<tr>
<td class="t_head">Challan No.</td>
<td class="lii undl">18584</td>
<td class="t_heada">Due Date:</td>
<td class="liia undl"></td>
</tr>
<tr>
<td class="t_head_c">Name</td>
<td colspan="3" class="lii undl">Hamza Zafeer</td>
</tr>
<tr>
<td>Program:</td>
<td class="lii undl de">BS Civil Tech </td>
<td >Roll No.</td>
<td class="undl"></td>
</tr>
<tr>
<td>Semester</td>
<td class="undl"></td>
<td>Session</td>
<td class="undl">2018-2021</td>
</tr>
</table>
<table style="width:99%" class="fee">
<tr>
<th >PARTICULARS</th>
<th>Rs.</th>
<th>Ps.</th>
</tr>
<tr>
<td>Registration Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Admission Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Tuition Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Laboratory Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Library Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Transcript / Degree Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Examination Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Security Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Hostel Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Transport charges</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Fine</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Misc.</td>
<td>1000</td>
<td></td>
</tr>
<tr>
<td>Total Payable</td>
<td>1000</td>
<td></td>
</tr>
</table>
<div class="btm">
<div class="fm rss"><strong>Rs. in words :</strong> One thousand only</div>
<div class="fm bt"> Cashier</div>
</div>
</div></div>
<div class="par_col">
<div class="column">
<img src="a.jpg" alt="test">
<table style="width:99%" class="feetop">
<tr>
<td class="t_head">Challan No.</td>
<td class="lii undl">18584</td>
<td class="t_heada">Due Date:</td>
<td class="liia undl"></td>
</tr>
<tr>
<td class="t_head_c">Name</td>
<td colspan="3" class="lii undl">Hamza Zafeer</td>
</tr>
<tr>
<td>Program:</td>
<td class="lii undl de">BS Civil Tech </td>
<td >Roll No.</td>
<td class="undl"></td>
</tr>
<tr>
<td>Semester</td>
<td class="undl"></td>
<td>Session</td>
<td class="undl">2018-2021</td>
</tr>
</table>
<table style="width:99%" class="fee">
<tr>
<th >PARTICULARS</th>
<th>Rs.</th>
<th>Ps.</th>
</tr>
<tr>
<td>Registration Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Admission Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Tuition Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Laboratory Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Library Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Transcript / Degree Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Examination Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Security Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Hostel Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Transport charges</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Fine</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Misc.</td>
<td>1000</td>
<td></td>
</tr>
</table>
<div class="btm">
<div class="fm rss"><strong>Rs. in words :</strong> One thousand only</div>
<div class="fm bt"> Cashier</div>
</div>
</div></div>
<div class="par_col">
<div class="column">
<img src="s.jpg" alt="test">
<table style="width:99%" class="feetop">
<tr>
<td class="t_head">Challan No.</td>
<td class="lii undl">18584</td>
<td class="t_heada">Due Date:</td>
<td class="liia undl"></td>
</tr>
<tr>
<td class="t_head_c">Name</td>
<td colspan="3" class="lii undl">Hamza Zafeer</td>
</tr>
<tr>
<td>Program:</td>
<td class="lii undl de">BS Civil Tech </td>
<td >Roll No.</td>
<td class="undl"></td>
</tr>
<tr>
<td>Semester</td>
<td class="undl"></td>
<td>Session</td>
<td class="undl">2018-2021</td>
</tr>
</table>
<table style="width:99%" class="fee">
<tr>
<th >PARTICULARS</th>
<th>Rs.</th>
<th>Ps.</th>
</tr>
<tr>
<td>Registration Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Admission Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Tuition Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Laboratory Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Library Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Transcript / Degree Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Examination Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Security Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Hostel Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Transport charges</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Fine</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Misc.</td>
<td>1000</td>
<td></td>
</tr>
</table>
<div class="btm">
<div class="fm rss"><strong>Rs. in words :</strong> One thousand only</div>
<div class="fm bt"> Cashier</div>
</div>
</div></div>
OUTPUT of HTML
But When i generate PDF, each section converted into a single page, and final PDF consisted on 3 pages.
Problem
It should not generate the 3 pages of PDF. Anybody can tell me what i am doing wrong, why it is creates 3 pages instead of 1 page?
I think it lacks the space, try to wrap your tables in one more table, like:
<table>
<tr>
<td>%table1HTML%</td>
</tr>
<tr>
<td>%table2HTML%</td>
</tr>
<tr>
<td>%table3HTML%</td>
</tr>
</table>
I am trying to display the array data into HTML table but table design or structure should be untouched irrespective of number of elements in array.
I tried some of logic like looping, but table structure changes.I don't want that.
Here is my code:
<?php
$goods=["ABC","XYZ","PQR","DEF"];
$qty=[12345,25120,14521,12541];
$rate=[12.00,13.02,15.00,14.00];
?>
<table>
<tr>
<th>Sr No.</th>
<th>Goods Description</th>
<th>Total Quantity(pcs)</th>
<th>Rate per unit(Rs.)</th>
<th colspan="3">Amount</th>
</tr>
<?php
for($i=0;$i<count($goods);$i++) {
?>
<tr>
<td><?php echo $goods[$i];?></td>
<td><?php echo $qty[$i];?></td>
<td><?php echo $rate[$i];?></td>
</tr>
<?php } ?>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>Total Value</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>Frieght</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>Total Taxable Value</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>Tax</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>tax</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>tax</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>Total Tax Amount</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>Grand Total Tax Amount</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>ABC</td>
<td></td>
<td></td>
</tr>
</table>
Expected Output:
Expected_output
I think this is what you need. You had not included the words in the loop.
It was insanely hard to write this code on the phone so there may be something left out.
$goods=["ABC","XYZ","PQR","DEF"];
$qty=[12345,25120,14521,12541];
$rate=[12.00,13.02,15.00,14.00];
$words=["Total Value", "Frieght", "Total Taxable Value", "Tax", "Tax", "Tax", "Total Tax Amount"];
?>
<table>
<tr>
<th>Sr No.</th>
<th>Goods Description</th>
<th>Total Quantity(pcs)</th>
<th>Rate per unit(Rs.)</th>
<th colspan="3">Amount</th>
</tr>
<?php
for ($i=0;$i<count($words);$i++) {
?>
<tr>
<td><?php echo $i+1 . "."; ?></td>
<td><?php if(isset($goods[$i])) echo $goods[$i];?></td>
<td><?php if(isset($qty[$i])) echo $qty[$i];?></td>
<td><?php if(isset($rate[$i])) echo $rate[$i];?></td>
<td><?php echo $words[$i];?></td>
</tr>
<?php } ?>
</table>
https://3v4l.org/f1BnW.
Edit forgot number on first column.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am trying to create a tournament table using PHP.
This is the HTML code sample.
<table>
<thead>
<tr>
<th>1</th>
<th>2</th>
<th>final</th>
<th>winner</th>
</tr>
</thead>
<tbody>
<tr>
<td class="team">team1</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td class="team">team1</td>
<td></td>
<td></td>
</tr>
<tr>
<td class="team">team2</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td class="team">team4</td>
<td></td>
</tr>
<tr>
<td class="team">team3</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td class="team">team4</td>
<td></td>
<td></td>
</tr>
<tr>
<td class="team">team4</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td class="team">team4 vinner</td>
</tr>
<tr>
<td class="team">team5</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td class="team">team6</td>
<td></td>
<td></td>
</tr>
<tr>
<td class="team">team6</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td class="team">team8</td>
<td></td>
</tr>
<tr>
<td class="team">team7</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td class="team">team8</td>
<td></td>
<td></td>
</tr>
<tr>
<td class="team">team8</td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
I tried creating that table using for loops, but that didn't work very well.
Maybe you can give some hints? I am out of ideas.
The elimination system you are working with is called "single elimination" (sometimes "head to head") and the output you wish to achieve is often called "brackets".
Have a look at:
Generate a single elimination tournament
and: PHP Single Elimination Tournament Table
This one can be helpful too: Tournament bracket placement algorithm
I am using third party code for HTML To PDF conversion is working good.But this cannot accept rowspan why?? Here is my code.
require('WriteHTML.php');
$pdf=new PDF_HTML();
$pdf->AliasNbPages();
$pdf->SetAutoPageBreak(true, 15);
$pdf->AddPage();
$pdf->SetFont('Arial','B',14);
$pdf->WriteHTML('<para><h1>Title</h1>');
$pdf->SetFont('Arial','B',7);
$htmlTable="<TABLE border='1'>
<TR height='40'>
<TD>S.NO</TD>
<TD>Type Of Beneficiary</TD>
<TD>Expected</TD>
<TD>No.Of Beneficiary</TD>
<TD>No.Of Packs Issued</TD>
<TD>Ave.monthly Usage</TD>
<TD>Balance Stock Available</TD>
</TR>
<TR>
<TD>1</TD>
<TD>Adolescents Girls</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD ></TD>
</TR>
<TR>
<TD rowspan='4'>2</TD>
<TD>Normal</TD>
<TD>ALLOTMENT NO</TD>
<TD>QUANTITY</TD>
<TD>QUANTITY</TD>
<TD>QUANTITY</TD>
<TD rowspan='4'></TD>
</TR>
<TR>
<TD>LSCS</TD>
<TD>ALLOTMENT NO</TD>
<TD>QUANTITY</TD>
<TD>QUANTITY</TD>
<TD>QUANTITY</TD>
</TR>
<TR>
<TD>Puperial Sterilization</TD>
<TD>ALLOTMENT NO</TD>
<TD>QUANTITY</TD>
<TD>QUANTITY</TD>
<TD>QUANTITY</TD>
</TR>
<TR>
<TD>Total</TD>
<TD>ALLOTMENT NO</TD>
<TD>QUANTITY</TD>
<TD>QUANTITY</TD>
<TD>QUANTITY</TD>
</TR>
<TR>
<TD>3</TD>
<TD>Women Prison Inmates</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR>
<TD>4</TD>
<TD>Women IMH Inmates</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR>
<TD>5</TD>
<TD>Total</TD>
<TD> </TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
</TABLE>";
$pdf->WriteHTML2("$htmlTable");
$pdf->Output();
It seems FPDF doesn't support rowspan:
FPDF does not recognize rowspan or colspan. Here is a workaround that
you can try, using empty cells and the border attribute for Cell.
by Sean (emphasis mine) - here is the full answer
Rowspan and Colspan supporting the TCPDF Library.And also easy configration this one. Library path http://www.tcpdf.org/ and coding path http://www.tcpdf.org/examples/example_048.phps. just change the path only. require_once('tcpdf.php');
I have a report to be exported in xls format. The report was exported successfully in xls format but gridlines never show up even I have adjusted some options in the ms excel by checking the view gridline checkbox but gridlines still show nothing. I have suspected if maybe there is something wrong with my php export code. can you please help me with this? Here is my code.
xls export code
<?php
$file="report.xls";
$export ='<center><h1 class="lead">CITY Chamber</h1><img src= "base_url(images/agri_logo.jpg)" width="130px" height="130px"></center>
<div id="page-wrapper">
<table class="table table-bordered table-hover table-striped tablesorter">
<tr>
<td>First Name: </td>
<td>'.$report_rows[0]->fname.'</td>
</tr>
<tr>
<td>Last Name: </td>
<td>'. $report_rows[0]->lname.'</td>
</tr>
<tr>
<td>Gender: </td>
<td>'.$report_rows[0]->gender.'</td>
</tr>
<tr>
<td>Contact Number: </td>
<td>'.$report_rows[0]->contact.'</td>
</tr>
</table>
<table class="table table-bordered table-hover table-striped tablesorter">
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped tablesorter">
<thead>
<tr>
<td colspan="2"><strong>Key Result Areas (KRA) / Program / Projects / Activities</strong></td>
<td><strong>Target</strong></td>
<td colspan="2" style="text-align:center;"><center> '.$report_rows[0]->prev_month_year.'</center></td>
<td colspan="2" ><center> '.$report_rows[0]->pres_month_year.' </center></td>
<td><strong>Total</strong></td>
</tr>
</thead>
<form id="at_report_form" method="post">
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td> '.$dropdown_brgy1[$data_reports['prev_brgy1']].' </td>
<td> '.$dropdown_brgy1[$data_reports['prev_brgy2']].' </td>
<td> '.$dropdown_brgy1[$data_reports['pres_brgy1']].' </td>
<td> '.$dropdown_brgy1[$data_reports['pres_brgy2']].' </td>
<td></td>
</tr>
<tr>
<td>1. KRA No. 1: Production Enhancement & Environment </td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td> Protection Agenda (PEEPA)</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>1.1 Support to Crop Production Enhancement </td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>1.1.1 Rice Production Self Sufficiency Program</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><span style="margin-left:30px;">a. Provision of certified seeds</span></td>
<td>no. of bags</td>
<td>per AT</td>
<td><center> '.$data_reports['a'].'</center></td>
<td> <center>'.$data_reports['b'].'</center></td>
<td><center> '.$data_reports['c'].'</center></td>
<td> <center>'.$data_reports['d'].'</center></td>
<td><center> '.$data_reports['total_1'].'</center></td>
</tr>
<tr>
<td></td>
<td>no. of farmers</td>
<td></td>
<td><center>'.$data_reports['e'].'</center></td>
<td><center>'.$data_reports['f'].'</center></td>
<td><center>'.$data_reports['g'].'</center></td>
<td><center>'.$data_reports['h'].'</center></td>
<td><center>'.$data_reports['total_2'].'</center></td>
</tr>
<tr>
<td style="text-align:center;">Rehab Seeds</td>
<td>no. of bags</td>
<td>per AT</td>
<td><center>'.$data_reports['i'].'</center></td>
<td><center>'.$data_reports['j'].'</center></td>
<td><center>'.$data_reports['k'].'</center></td>
<td><center>'.$data_reports['l'].'</center></td>
<td><center>'.$data_reports['total_3'].'</center></td>
</tr>
<tr>
<td></td>
<td>no. of farmers</td>
<td></td>
<td><center>'.$data_reports['m'].'</center></td>
<td><center>'.$data_reports['n'].'</center></td>
<td><center>'.$data_reports['o'].'</center></td>
<td><center>'.$data_reports['p'].'</center></td>
<td><center>'.$data_reports['total_4'].'</center></td>
</tr>
<tr>
<td><span style="margin-left:30px;">b. Provision of pest control assistance</span></td>
<td>no. of kgs (ratoxin)</td>
<td>per AT</td>
<td><center>'.$data_reports['q'].'</center></td>
<td><center>'.$data_reports['r'].'</center></td>
<td><center>'.$data_reports['s'].'</center></td>
<td><center>'.$data_reports['t'].'</center></td>
<td><center>'.$data_reports['total_5'].'</center></td>
</tr>
</tbody>
</form>
</table></div></div>';
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file");
echo $export; ?>
Output (Gridlines never show up even I have checked the gridlines view checkbox):
optput ur html using table tags
use
<table border=1>