Advertisement
phpbego

printpdf

Jul 7th, 2014
991
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. <?php
  2. require "koneksi.php";
  3.  
  4.         $s = $mysqli->query("SELECT * FROM krs");
  5.         $strhtml = "<h3>Kartu Rencana Studi</h3>";
  6.         $strhtml .= "<table>
  7.             <tr>
  8.                 <th>No</th>
  9.                 <th>Kode</th>
  10.                 <th>Nama Matakuliah</th>
  11.                 <th>SKS</th>
  12.                 <th>Dosen</th>
  13.             </tr>";
  14.         $no = 0;
  15.         while ($row = mysqli_fetch_array($s)){
  16.         $no++;
  17.         $strhtml .= "<tr>
  18.                 <td>$no</td>
  19.                 <td>$row[kode]</td>
  20.                 <td>$row[nama]</td>
  21.                 <td>$row[sks]</td>
  22.                 <td>$row[dosen]</td>
  23.            </tr>";
  24.         }
  25.         $strhtml .= "</table>";
  26.         $now = date("F j, Y, g:i a");
  27.         $strhtml .= "<p>Dicetak Pada : $now <p>";
  28.  
  29. // Panggil mPdf
  30. require ("mpdf/mpdf.php");
  31.  
  32. $stylesheet = file_get_contents('css/style.css');
  33. $fileName = 'reportPdf--' . date('d-m-Y') . '-' . date('h.i.s');
  34.  
  35. $mpdf = new mPDF('utf-8', 'A4', 0, '', 10, 10, 5, 1, 1, 1, '');
  36. //$mpdf->SetDisplayMode('fullpage');
  37. $mpdf->WriteHTML($stylesheet,1);
  38. $mpdf->WriteHTML($strhtml);
  39. $mpdf->Output('files/' . $fileName. '.pdf','D');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement