first(); self::$gutachter = Gutachter::where('id', self::$projekt->gutachter_id)->first(); self::$auftraggeber = Auftraggeber::where('id', self::$projekt->auftraggeber_id)->first(); $headers = [ 'Content-Type: application/pdf', 'Cache-Control: max-age=0', 'Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT', 'Cache-Control: cache, must-revalidate', ]; $filepath = Storage::disk('public')->path("/download/$projekte_id/"); $filename = \ucfirst($type).' '.preg_replace("'[^0-9a-zA-Z]'", '', self::$projekt->interner_name).'.pdf'; // if ($type == 'nutzwerte') { // if ($mode == 'new') { // Projekte::where('id', $projekte_id)->update(['pdf_nutzwerte_name' => '', 'pdf_nutzwerte_status' => 1]); // } else { // return Response::download($file, $filename, $headers); // } // } if (! File::isDirectory($filepath)) { File::makeDirectory($filepath, 0777, true, true); } $file = $filepath.$filename; ob_start(); $mpdf = new Mpdf( [ 'debug' => true, 'mode' => 'utf-8', 'format' => 'A4-P', 'margin_left' => 10, 'margin_right' => 10, 'margin_top' => 12, 'margin_bottom' => 20, 'margin_header' => 0, 'margin_footer' => 0, ] ); $stylesheet = file_get_contents(__DIR__.'/../../../resources/css/pdf-download.css'); $mpdf->WriteHTML($stylesheet, HTMLParserMode::HEADER_CSS); $mpdf->SetTitle($filename); $mpdf->SetCreator('nutzwerte.at'); $mpdf->SetAuthor(self::$gutachter->title.' '.self::$gutachter->gender.' '.self::$gutachter->name); $inhaltesverzeichnis = ProjektInhaltsverzeichnis::where('projekte_id', $projekte_id)->where('part', $type)->orderBy('sort')->get(); $platzhalter = Platzhalter::load($projekte_id); foreach ($inhaltesverzeichnis as $inhalt) { if ($inhalt->neue_seite) { $mpdf->AddPage(); } $html = ''; $html = Ueberschrift::load($inhalt); if ($inhalt->textblock) { $textblock = Platzhalter::replace($platzhalter, $inhalt->textblock); $textblock = Format::fix_str($textblock); if ($inhalt->inhaltselement_id != '9') { $html .= $textblock; } } if ($inhalt->textblock2) { $textblock2 = Platzhalter::replace($platzhalter, $inhalt->textblock2); $textblock2 = Format::fix_str($textblock2); } switch ($inhalt->inhaltselement_id) { case '9': $html .= Deckblatt::load($inhalt, $textblock, $textblock2); break; case '1': $html .= Inhalt::load($projekte_id); break; case '3': $html .= Paragraph6::load($projekte_id); break; case '4': $html .= Allgemeinflaechen::load($projekte_id); break; case '5': $html .= ZuUndAbschlaege::load($projekte_id); break; case '7': $html .= Zusammenstellung::load($projekte_id); break; case '8': // AUFTRAGGEBER $str = RichContentRenderer::make(self::$auftraggeber->referenz_formatting)->toHtml(); $html .= Format::fix_str($str); break; // case '11': // $html .= DigitaleSignatur::load($projekte_id); // break; } if ($inhalt->textblock2 and $inhalt->inhaltselement_id != 9) { $html .= $textblock2; } if ($inhalt->seitenzahl_anzeige == 1) { $mpdf->SetHTMLFooter('
Seite {PAGENO}

'); } if ($html) { $mpdf->WriteHTML($html, HTMLParserMode::HTML_BODY); } } ob_clean(); $mpdf->Output($file, 'F'); return Response::download($file, $filename, $headers); } }