EVOLUTION-NINJA
Edit File: pdfindex.php
<?php tcpdf(); $obj_pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $obj_pdf->SetCreator(PDF_CREATOR); $title = "PDF Report"; $obj_pdf->SetTitle($title); $obj_pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $title, PDF_HEADER_STRING); $obj_pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $obj_pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $obj_pdf->SetDefaultMonospacedFont('helvetica'); $obj_pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $obj_pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $obj_pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $obj_pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $obj_pdf->SetFont('helvetica', '', 9); $obj_pdf->setFontSubsetting(false); $obj_pdf->AddPage(); ob_start(); // we can have any view part here like HTML, PHP etc //display data start //foreach($getalldata as $f_table) $query = "select * from $getalldata"; $result = mysql_query($query); if (!$result) { $message = 'ERROR:' . mysql_error(); return $message; } else { $i = 0; echo '<table border="1" style="width:100%"><tr>'; while ($i < mysql_num_fields($result)) { $meta = mysql_fetch_field($result, $i); echo '<td>' . $meta->name . '</td>'; $i = $i + 1; } echo '</tr>'; $i = 0; while ($row = mysql_fetch_row($result)) { echo '<tr>'; $count = count($row); $y = 0; while ($y < $count) { $c_row = current($row); echo '<td>' . $c_row . '</td>'; next($row); $y = $y + 1; } echo '</tr>'; $i = $i + 1; } echo '</table>'; mysql_free_result($result); } //display data end $content = ob_get_contents(); ob_end_clean(); $obj_pdf->writeHTML($content, true, false, true, false, ''); $obj_pdf->Output('output.pdf', 'I'); ?>