emprit

print.php

Nov 2nd, 2012
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.24 KB | None | 0 0
  1. ---------- Controller----------------
  2. <?php
  3. class Cetak_biodata_pelamar extends CI_Controller {
  4.  
  5. function Header($pdf)
  6.         {      
  7.         //   $pdf->Image('logo.php',2,1,2);
  8.            $pdf->SetFont('Times','B','12');
  9.             $pdf->Cell(17,0.5,'',0,0,'C');
  10.             $pdf->Ln();
  11.             $pdf->Ln();
  12.             $pdf->Cell(17,0.5,'ABSENSI RE-ORGANISASI FTIK ',0,0,'C');
  13.             $pdf->Ln();
  14.             $pdf->Cell(17,0.5,'Tahun Akademik 2012-2013 ',0,0,'C');
  15.             $pdf->Ln();
  16.             $pdf->SetFont('Times','B','14');
  17.             $pdf->Line(2,3.5,19,3.5);
  18.             $pdf->Line(2,3.37,19,3.37);
  19.             $pdf->Ln();
  20.             $pdf->SetFont('Times','','12');
  21.             $pdf->Cell(17,0.5,'',0,1,'C');
  22.             $pdf->Cell(17,0.5,'Daftar Absensi',0,1,'C');
  23.             $pdf->Ln();
  24.             $pdf->SetFont('Times','B','12');
  25.             $pdf->Ln();
  26.        }   
  27.    
  28.     function index(){
  29.         require_once(APPPATH . 'third_party/tcpdf/config/lang/eng.php');
  30.         require_once(APPPATH . 'third_party/tcpdf/tcpdf.php');
  31.        
  32.         $no_urut = $this->session->userdata('no_urut');
  33.         $detail = $this->pelamar_model->caridata($no_urut);
  34. // create new PDF document
  35. $pdf = new TCPDF('P','cm','A4');
  36.  
  37. // set document information
  38. $pdf->SetCreator(PDF_CREATOR);
  39. $pdf->SetAuthor('Emprit');
  40. $pdf->SetTitle('Biodata Pelamar');
  41. $pdf->SetSubject('Biodata untuk '.$this->session->userdata('username'));
  42.  
  43. $pdf->setPrintHeader(true);
  44. $this->Header($pdf);
  45. $pdf->setPrintFooter(false);
  46.  
  47. // set default monospaced font
  48. $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  49.  
  50. //set margins
  51. $pdf->SetMargins(2,4.5,2);
  52.  
  53. //set auto page breaks
  54. $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  55.  
  56. //set image scale factor
  57. $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  58.  
  59. //set some language-dependent strings
  60. $pdf->setLanguageArray($l);
  61. // ---------------------------------------------------------
  62.  
  63. // add a page
  64. $pdf->AddPage();
  65. $pdf->SetFont('times', '', 12);
  66.  
  67. foreach($query->row() as $row){
  68. $pdf->Cell(0.7,0.5,'No Urut Pelamar',1,0,'C');
  69. $pdf->Cell(0.2,0.5,':',1,0,'C');
  70. $pdf->Cell(0.7,0.5,$row->no_urut,1,1,'C');
  71. }
  72.  
  73. $pdf->Output("Biodata-".$this->session->userdata('username') ."pdf","D");
  74.     }
  75. }
  76. ?>
  77.  
  78. ----------------- Model --------------------------
  79.     function caridata($no_urut) {
  80.         $query = $this->db->query("select * from biodata_pelamar where no_urut= '$no_urut'");
  81.         return $query;
  82.         }
Advertisement
Add Comment
Please, Sign In to add comment