Skip to main content

FPDF dengan CodeIgniter

Cetak Surat Keputusan

Controller:

<?php


//File in controller named surat_keputusan.php

defined('BASEPATH') OR exit('No direct script access allowed');

class Cetak_surat_keputusan extends CI_Controller {

public function __construct()
    {
        parent::__construct();
        $this->load->helper('url');
        $this->load->database();       
        $this->db->select();
        $this->db->from('surat.config_sk');       
        $query = $this->db->get();
       
        return $query->result();
       
    }

public function index()
{
        if(isset($_GET['id_sk'])){
           
        date_default_timezone_set('Asia/Jakarta');
           
            $query=$this->load->database('surat',TRUE)->get_where('config_sk',array('id_sk'=>$_GET['id_sk']));
            $data_sk=array(
                'id_sk'=>'',
                'sk_nomor'=>'',
                'sk_kelompok'=>'',
                'sk_judul_1'=>'',
                'sk_judul_2'=>'',
                'sk_judul_3'=>'',
                'sk_judul_4'=>'',
                'sk_judul_5'=>'',               
                'sk_tanggal'=>'',
                'sk_rektor'=>'',
                'sk_rektor_nik'=>'',               
            );
            if($query->num_rows()>0){
                $row=$query->row();
                $data_sk['id_sk']=$row->id_sk;
                $data_sk['sk_nomor']=$row->sk_nomor;
                $data_sk['sk_kelompok']=$row->sk_kelompok;               
                $data_sk['sk_judul_1']=$row->sk_judul_1;
                $data_sk['sk_judul_2']=$row->sk_judul_2;
                $data_sk['sk_judul_3']=$row->sk_judul_3;
                $data_sk['sk_judul_4']=$row->sk_judul_4;
                $data_sk['sk_judul_5']=$row->sk_judul_5;               
               
                $data_sk['sk_tanggal']=$row->sk_tanggal;
                $data_sk['sk_rektor']=$row->sk_rektor;
                $data_sk['sk_rektor_nik']=$row->sk_rektor_nik;               
            }

            //jarak_dan_ukuran
            $jarak_atas = '0.5'; $jarak_kiri = '4'; $panjang_gambar = '0.7'; $tinggi_gambar = '1'; $jarak_titik_dua_dari_pinggir = '1.2'; $jarak_isi_dari_titik_dua = '0.1'; $lebar_isi = '7'; $lebar_isi_dalam = '5.4'; $lebar_isi_dalam_nomor = '5.2'; $jarak_tembusan = '2';
            //   
            //jarak_dan_ukuran
            $jarak_atas = '0.5'; $jarak_kiri = '4'; $panjang_gambar = '0.7'; $tinggi_gambar = '1'; $jarak_titik_dua_dari_pinggir = '1.2'; $jarak_isi_dari_titik_dua = '0.1'; $lebar_isi = '7'; $lebar_isi_dalam = '5.4'; $lebar_isi_dalam_nomor = '5.2'; $jarak_tembusan = '2';
            //
           
        //STANDART
                $this->load->library('fpdf_gen');       
                $this -> fpdf=new FPDF('P','in',array(8.5,10.7)); 
                $this -> fpdf->AddPage();
       
        // FONT
            $jenis_font_reguler= 'BOOKOS';
            $jenis_font_italic= 'BOOKOSI';
            $jenis_font_bold= 'BOOKOSB';

            $this -> fpdf->AddFont($jenis_font_reguler,'','BOOKOS.php');
            $this -> fpdf->AddFont($jenis_font_italic,'','BOOKOSI.php');
            $this -> fpdf->AddFont($jenis_font_bold,'','BOOKOSB.php');
            $this -> fpdf->SetFillColor(255,0,0); $ukuran_font='11';

        $this->fpdf->SetFont($jenis_font_bold,'',$ukuran_font);
       
        $this->fpdf->SetFillColor(255,0,0);
//ISI

//LogoUII

  $this->fpdf->Image('http://localhost/administrasi/assets/images/uii.png',$jarak_kiri,$jarak_atas,$panjang_gambar,$tinggi_gambar);

//JUDUL
        $this->fpdf->ln(1.3);
        $this->fpdf->Cell(0.5); //jarak dari pinggir
        $this->fpdf->Cell($lebar_isi,0.2,'SURAT KEPUTUSAN REKTOR UNIVERSITAS ISLAM INDONESIA',0,0,'C',0,'');
        $this->fpdf->SetFont($jenis_font_reguler,'',$ukuran_font);

        $this->fpdf->ln(0.2);
        $this->fpdf->Cell(0.5);
        //NOMOR_SURAT
            $bulan = $data_sk['sk_tanggal'];
            //bulan_romawi
            $bulan_romawi = date('m', strtotime($data_sk['sk_tanggal']));
            $dayList = array(
                    '01' => 'I',
                    '02' => 'II',
                    '03' => 'III',
                    '04' => 'IV',
                    '05' => 'V',
                    '06' => 'VI',
                    '07' => 'VII',
                    '08' => 'VIII',
                    '09' => 'IX',
                    '10' => 'X',
                    '11' => 'XI',
                    '12' => 'XII'
                );
           
        if ($data_sk['sk_nomor'] <> ""){$nomor_surat_cetak=$data_sk['sk_nomor'];}else{$nomor_surat_cetak= "      ";}

        $this->fpdf->Cell($lebar_isi,0.2, 'NOMOR '. $nomor_surat_cetak . '/SK-Rek/'. $data_sk['sk_kelompok'] .'/'. $dayList[$bulan_romawi]. '/' . date('Y', strtotime($data_sk['sk_tanggal'])) ,0,0,'C',0,'');
       
        $this->fpdf->SetFont($jenis_font_bold,'',$ukuran_font);

        $this->fpdf->ln(0.2);
        $this->fpdf->Cell(0.5);
        $this->fpdf->Cell($lebar_isi,0.2,'TENTANG',0,0,'C',0,'');
       
//JUDUL 10
$this->fpdf->ln(0.2);
       
if ($data_sk['sk_judul_1'] == null) {} else {
    $this->fpdf->Cell(0.5);
    $this->fpdf->MultiCell($lebar_isi,0.2,$data_sk['sk_judul_1'],0,'C',0);
}

if ($data_sk['sk_judul_2'] == null) {} else {
    $this->fpdf->Cell(0.5);
    $this->fpdf->MultiCell($lebar_isi,0.2,$data_sk['sk_judul_2'],0,'C',0);
}

if ($data_sk['sk_judul_3'] == null) {} else {
    $this->fpdf->Cell(0.5);
    $this->fpdf->MultiCell($lebar_isi,0.2,$data_sk['sk_judul_3'],0,'C',0);
}

if ($data_sk['sk_judul_4'] == null) {} else {
    $this->fpdf->Cell(0.5);
    $this->fpdf->MultiCell($lebar_isi,0.2,$data_sk['sk_judul_4'],0,'C',0);
}

if ($data_sk['sk_judul_5'] == null) {} else {
    $this->fpdf->Cell(0.5);
    $this->fpdf->MultiCell($lebar_isi,0.2,$data_sk['sk_judul_5'],0,'C',0);
    $this->fpdf->ln(0.1);
}

//bismillah
$this->fpdf->ln(0.1); $this->fpdf->Cell(0.5); $this->fpdf->SetFont($jenis_font_italic,'',$ukuran_font);
$this->fpdf->Cell($lebar_isi,0.2,'Bismillahirrahmanirrahiim',0,0,'C',0,'');

$this->fpdf->ln(0.3); $this->fpdf->Cell(0.5); $this->fpdf->SetFont($jenis_font_reguler,'',$ukuran_font);
$this->fpdf->Cell($lebar_isi,0.2,'REKTOR UNIVERSITAS ISLAM INDONESIA,',0,0,'C',0,'');
       
//TANDA TANGAN REKTOR
//bismillah
$this->fpdf->ln(0.2);
$this->fpdf->SetFont($jenis_font_italic,'',$ukuran_font);
$this->fpdf->Cell(8,0.2,'Billahitaufiq wal hidayah',0,0,'C',0,'');       

//--------------- TANDA TANGAN REKTOR
$this->fpdf->SetFont($jenis_font_reguler,'',$ukuran_font);
$this->fpdf->ln(0.3);
$this->fpdf->Cell(4);
$this->fpdf->MultiCell(4,0.3,'Ditetapkan di Yogyakarta',0,'',0);
$this->fpdf->Cell(4); //jarak dari pinggir
$this->fpdf->Cell(1,0.2,"Pada tanggal: ",0,0,'11');//lebar kolom b.
$this->fpdf->SetFont($jenis_font_reguler,'U',$ukuran_font);
$this->fpdf->Cell(0.1); //jarak antara c. dan Bahwa

//
$tahun_sk = date('Y', strtotime($data_sk['sk_tanggal']));
$list_bulan = array(
        '01' => 'Januari',
        '02' => 'Februari',
        '03' => 'Maret',
        '04' => 'April',
        '05' => 'Mei',
        '06' => 'Juni',
        '07' => 'Juli',
        '08' => 'Agustus',
        '09' => 'September',
        '10' => 'Oktober',
        '11' => 'November',
        '12' => 'Desember'
    );
   
$bulan_sk = $list_bulan[date('m', strtotime($data_sk['sk_tanggal']))];

if($data_sk['sk_nomor'] == null){$tanggal_sk = '    ';
}else
{$tanggal_sk = date('d', strtotime($data_sk['sk_tanggal']));}

//HIJRIYAH
//hijriah
            function makeInt($angka)
            {
            if ($angka < -0.0000001)
            {
            return ceil($angka-0.0000001);
            }
            else
            {
            return floor($angka+0.0000001);
            }
            }

            function konvhijriah($tanggal)
            {
            $array_bulan = array("Muharram", "Safar", "Rabiul Awwal", "Rabiul Akhir",
            "Jumadil Awwal","Jumadil Akhir", "Rajab", "Sya’ban",
            "Ramadhan","Syawwal", "Dzulqaidah", "Dzulhijjah");

            $date = makeInt(substr($tanggal,8,2));
            $month = makeInt(substr($tanggal,5,2));
            $year = makeInt(substr($tanggal,0,4));
            if (($year>1582)||(($year == "1582") && ($month > 10))||(($year == "1582") && ($month=="10")&&($date >14)))
            {
            $jd = makeInt((1461*($year+4800+makeInt(($month-14)/12)))/4)+
            makeInt((367*($month-2-12*(makeInt(($month-14)/12))))/12)-
            makeInt( (3*(makeInt(($year+4900+makeInt(($month-14)/12))/100))) /4)+
            $date-32075;
            }
            else
            {
            $jd = 367*$year-makeInt((7*($year+5001+makeInt(($month-9)/7)))/4)+
            makeInt((275*$month)/9)+$date+1729777;
            }

            $wd = $jd%7;
            $l = $jd-1948440+10632;
            $n=makeInt(($l-1)/10631);
            $l=$l-10631*$n+354;
            $z=(makeInt((10985-$l)/5316))*(makeInt((50*$l)/17719))+(makeInt($l/5670))*(makeInt((43*$l)/15238));
            $l=$l-(makeInt((30-$z)/15))*(makeInt((17719*$z)/50))-(makeInt($z/16))*(makeInt((15238*$z)/43))+29;
            $m=makeInt((24*$l)/709);
            $d=$l-makeInt((709*$m)/24);
            $y=30*$n+$z-30;
            $g = $m-1;

            /* $final = "     $array_bulan[$g] $y H"; */
            /* $final = "$d $array_bulan[$g] $y H";   */
            $final = " " . "$d $array_bulan[$g] $y H";
            return $final;
            }

//HIJRIYAH
            $datehijriah = konvhijriah($data_sk['sk_tanggal']);
            $this->fpdf->MultiCell(2.5,0.2, ' '. $datehijriah,0,'L',0);

//tanggal
$this->fpdf->SetFont($jenis_font_reguler,'',$ukuran_font);
$this->fpdf->Cell(5);
$this->fpdf->MultiCell(4,0.2,'   ' . $tanggal_sk .' '. $bulan_sk .' '. $tahun_sk .' M',0,'L',0);
/* $this->fpdf->MultiCell(4,0.2,$datehijriah ,0,'L',0); */

$this->fpdf->ln(0.05);
$this->fpdf->Cell(4);
$this->fpdf->MultiCell(4,0.2,'Rektor,',0,'L',0);

$this->fpdf->ln(0.8);
$this->fpdf->Cell(4);
$this->fpdf->MultiCell(4,0.2,$data_sk['sk_rektor'],0,'L',0);
$this->fpdf->Cell(4);
$this->fpdf->MultiCell(4,0.2,$data_sk['sk_rektor_nik'],0,'L',0);

//TEMBUSAN

//SELESAI
       
/*         echo $this->fpdf->Output('hello_world.pdf','D'); */
        echo $this->fpdf->Output('I');
       
    }

    }   
}



Libraries: fpdf_gen.php

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
* Name:  FPDF
*
* Author: Jd Fiscus
*            jdfiscus@gmail.com
*         @iamfiscus
*         
*
* Origin API Class: http://www.fpdf.org/
*
* Location: http://github.com/iamfiscus/Codeigniter-FPDF/
*         
* Created:  06.22.2010
*
* Description:  This is a Codeigniter library which allows you to generate a PDF with the FPDF library
*
*/

class Fpdf_gen {
       
    public function __construct() {
       
        require_once APPPATH.'third_party/fpdf/fpdf-1.8.php';
        define('FPDF_FONTPATH', APPPATH.'third_party/fpdf/font/');
               
        $pdf = new FPDF();
        $pdf->AddPage();

        $CI =& get_instance();
        $CI->fpdf = $pdf;
       
    }
   
}

Comments

  1. Sands Casino Resort: Resorts & Casinos | Tucson, Arizona
    At Sands Casino Resort we operate with 인카지노 the highest standard of security and the highest standard of security available 메리트카지노 to all. We're septcasino here to help make your gaming

    ReplyDelete

Post a Comment

Popular posts from this blog

aktifkan SSH

Cara mengaktifkan SSH di Windows 10   December 19, 2017     Jaringan ,  Keamanan ,  SSH ,  Windows Dulu ketika kita ingin meremote server linux menggunakan aplikasi SSH dari sistem operasi Windows, kita harus menggunakan aplikasi pihak ketiga seperti PuTTY. Sekarang setelah ada update terbaru, sistem operasi Windows 10 sudah memiliki aplikasi SSH. SSH? ya anda tidak salah baca, Windows sekarang sudah memiliki aplikasi SSH (client dan server) sendiri, bukan pihak ketiga. Berikut beberapa tutorial SSH yang pernah saya tulis sebelumnya: cara remote login ke ubuntu server dengan SSH cara memperbaiki failed remote host identification file transfer menggunakan aplikasi SSH dan MC cara remote login dengan ssh tanpa password cara membatasi hak akses login melalui SSH di Ubuntu Server fungsi remote host identification di SSH   mengaktifkan user root pada remote login SSH Lalu bagaimana cara mengaktifkan aplikasi built in SSH di windows 10? Anda harus melakukan upda

Hack File .xlsb

For first you must create a backup copy of your Workbook!!! Then you have to rename the XLSB file with ZIP extension. Test.XLSB => Test.ZIP             Opening your ZIP file using a compression software (e.g. WinRar) I can see the content of the file, structured in folders Inside the folder xl you can find a binary file named vbaProject.bin. Extract it on your desktop and edit it using a text editor. In my case I used Notepad++. Using the Find function of your editor, you must search the text DPB And replace the DPB string with DPx Then save the vbaProject.bin and replace this file inside the .ZIP File, renaming then .ZIP file in XLSB. Reopening the XLSB file using Excel, you will get an error message: you have to answer Yes to this error message. Then  Save , Close and Reopen your XLSB file. Now, if you go to VBA Editor (ALT + F11), you can see and edit all project files. B. And FIle