예제 #1
0
 /**
  * Erzeugt ein PDF auf Basis der übergebenen Funktion.
  * @param $module
  * @param $action
  * @param $param
  * @param null $filename falls kein Dateiname angegeben wird, wird das PDF direkt im Browser ausgegeben
  * @throws \Exception
  */
 public static function generate($module, $action, $param, $filename = null, $template = true, $margin = 0)
 {
     $druckinhalt = new WrapperControl(null, 'druck');
     $druckinhalt->setModule($module)->setAction($action)->addParams($param);
     $pdf = new \mPDF('de-DE', 'A4');
     $pdf->SetDisplayMode('fullpage');
     // Zeigt eine ganze Seite an, wenn das PDF in Acrobat geöffnet wird
     if ($margin > 0) {
         $pdf->SetTopMargin($margin);
     }
     $pdf->SetFooter('Seite {PAGENO} / {nb}');
     //file_get_contents('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css') .
     $stylesheet = file_get_contents('templates/print/css/default.css');
     $pdf->WriteHTML($stylesheet, 1);
     if ($template && file_exists('site/Print.template.html')) {
         $vars = ['heading' => Application::getCurrentResponse()->getMetadata()->getHeading()];
         $header = Parser::parse(null, null, $vars, file_get_contents('site/Print.template.html'));
         $pdf->WriteHTML($header, 2);
     }
     $pdf->WriteHTML($druckinhalt->toHtml(), 2);
     if ($filename === null) {
         $pdf->Output($module . $action . '.pdf', 'I');
     } else {
         //$filename = Files::validateFilename($filename);
         $pdf->Output($filename, 'F');
     }
     unset($pdf);
 }
 public function toHtml()
 {
     if ($this->artikel == null) {
         return '';
     } else {
         $this->setModule('Cms');
         $this->setAction('show');
         $this->addParam('id', $this->artikel->id);
         return '<div class="alert alert-info" role="alert">
                 <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
             ' . parent::toHtml() . '</div>';
     }
 }