Advertisement
Frahman

Controller Asrama

Feb 23rd, 2024
791
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.36 KB | Source Code | 0 0
  1. public function generatePDF()
  2.     {
  3.         $siswa = $this->AsramaModel->getData();
  4.         $setting = $this->AdminModel->getAll();
  5.         $data = [
  6.             'title' => 'Biodata Siswa',
  7.             'setting' => $this->AdminModel->getAll(),
  8.             'row' => $this->TahunAjaranModel->getAktif(),
  9.             'jalur' => $this->JalurModel->getAktif(),
  10.             'siswa' => $this->AsramaModel->getData(),
  11.             'prestasi' => $this->DetailPrestasiModel->getAll_detail_prestasi(),
  12.             'foto_siswa' => $this->getImageDataFromDatabase(),
  13.         ];
  14.         // Load Dompdf options
  15.         $options = new Options();
  16.         $options->set('isPhpEnabled', true); // Aktifkan PHP
  17.         $options->set('isHtml5ParserEnabled', true); // Aktifkan parser HTML5
  18.         $options->set('isRemoteEnabled', true); // Aktifkan akses URL eksternal
  19.  
  20.         // Instantiate Dompdf class with options
  21.         $dompdf = new Dompdf($options);
  22.  
  23.         // Load HTML content from view
  24.         $viewContent = view('siswa/asrama/coba', $data);
  25.  
  26.         // Load HTML into Dompdf
  27.         $dompdf->loadHtml($viewContent);
  28.  
  29.         // Set paper size and orientation
  30.         $dompdf->setPaper('A4', 'portrait');
  31.  
  32.  
  33.         // Render PDF
  34.         $dompdf->render();
  35.  
  36.         // Output PDF to browser
  37.         $dompdf->stream("example.pdf", array("Attachment" => false));
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement