Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function print_card($employee_id)
- {
- $detail = $this->employee_m->select_by_id($employee_id)->row();
- $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
- $pdf->SetTitle('Cetak Kartu NPWPD');
- $pdf->setPrintHeader(false);
- $pdf->setPrintFooter(false);
- $pdf->setFontSubsetting(true);
- $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
- $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
- $pdf->SetMargins(3.0, 25, 3.0); // left = 0.5 cm, top = 25 cm, right = 2.5cm
- $pdf->SetFooterMargin(1.5); // the bottom margin has to be set with SetFooterMargin
- $pdf->SetAutoPageBreak(true, 0);
- // set some language-dependent strings (optional)
- if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
- require_once dirname(__FILE__) . '/lang/eng.php';
- $pdf->setLanguageArray($l);
- }
- $pdf->SetFont('helvetica', '', 10, '', true);
- $pagelayout = array(54, 85);
- $pdf->AddPage('L', $pagelayout);
- $style = array(
- 'position' => '',
- 'align' => 'L',
- 'stretch' => false,
- 'fitwidth' => true,
- 'cellfitalign' => '',
- 'border' => false,
- 'hpadding' => 'auto',
- 'vpadding' => 'auto',
- 'fgcolor' => array(0, 0, 0),
- 'bgcolor' => false,
- 'text' => false,
- 'font' => 'helvetica',
- 'fontsize' => 8,
- 'stretchtext' => 3,
- );
- $pdf->Cell(0, 0, $detail->employee_npwpd, 0, 1); // NPWPD
- $pdf->Cell(0, 0, $detail->employee_name, 0, 1); // Nama
- $pdf->Cell(0, 0, $detail->employee_address, 0, 1); // Alamat
- $pdf->write1DBarcode($detail->employee_npwpd, 'C39', '', '', '', 12, 0.4, $style, 'N');
- $time = time();
- $filename = 'Kartu_NPWPD_' . $detail->employee_npwpd . '_' . $time;
- $pdfFilePath = FCPATH . "download/$filename.pdf";
- $pdf->Output($pdfFilePath, 'F');
- header("Content-type: application/pdf");
- header("Content-Length:" . filesize($pdfFilePath));
- readfile($pdfFilePath);
- exit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement