private function toPdf($html)
 {
     $pdf = new \mikehaertl\wkhtmlto\Pdf($html);
     $pdf->binary = '/usr/local/bin/wkhtmltopdf';
     $pdf->setOptions(['ignoreWarnings' => true]);
     if ($html = $pdf->toString()) {
         return $html;
     }
     throw new \exception('Failed To write PDF with message: ' . $pdf->getError());
 }
Exemple #2
0
 public function print_kartu()
 {
     $registrant = $this->session->registrant;
     if (!empty($registrant)) {
         $pdf = new mikehaertl\wkhtmlto\Pdf();
         $pdf->setOptions($this->pdfOption());
         $reg_data = $this->load->view('registrant/print', ['registrant' => $registrant], true);
         $pdf->addPage($reg_data);
         $res = $pdf->send('Kartu Pendaftaran ' . $registrant->getId() . ' .pdf');
         if (!$res) {
             echo $pdf->getError();
         }
     } else {
         $this->session->set_flashdata("errors", [0 => "Maaf, Anda tidak boleh melihat halaman ini lagi!"]);
         redirect('login/index');
     }
 }