Пример #1
0
 public function actionImprimir()
 {
     // get your HTML raw content without any layouts or scrip
     $pasostramite = pasostramite::find()->all();
     $content = $this->renderPartial('_imprimir', ['pasostramite' => $pasostramite]);
     $header = $this->renderPartial('_header', ['pasostramite' => $pasostramite]);
     $pdf = new Pdf(['format' => Pdf::FORMAT_A4, 'orientation' => Pdf::ORIENT_PORTRAIT, 'destination' => Pdf::DEST_BROWSER, 'content' => $content, 'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css', 'cssInline' => '.kv-heading-1{font-size:18px}', 'options' => ['title' => 'Krajee Report Title'], 'methods' => ['SetHeader' => $header, 'SetFooter' => ['{PAGENO}']]]);
     // return the pdf output as per the destination setting
     return $pdf->render();
 }
Пример #2
0
 public function actionImprimirFiltro()
 {
     //echo'<pre>';print_r($_GET);echo'</pre>'; exit;
     $fechaInicial = date("d-m-Y", strtotime($_GET['fechas']["filtro"]["fechaInicial"]));
     $fechaFinal = date("d-m-Y", strtotime($_GET['fechas']["filtro"]["fechaFinal"]));
     $formato = 'fecha_ft >= "' . $fechaInicial . '" and fecha_ft <= "' . $fechaFinal . '"';
     $VisitasEscuelas = VisitasEscuelas::find()->where('fecha_ft >= :fechaInicial and fecha_ft <= :fechaFinal', ['fechaInicial' => $fechaInicial, 'fechaFinal' => $fechaFinal])->all();
     $content = $this->renderPartial('_imprimir', ['VisitasEscuelas' => $VisitasEscuelas]);
     $header = $this->renderPartial('_header', ['VisitasEscuelas' => $VisitasEscuelas]);
     $pdf = new Pdf(['format' => Pdf::FORMAT_A4, 'orientation' => Pdf::ORIENT_PORTRAIT, 'destination' => Pdf::DEST_BROWSER, 'content' => $content, 'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css', 'cssInline' => '.kv-heading-1{font-size:18px}', 'options' => ['title' => 'Krajee Report Title'], 'methods' => ['SetHeader' => $header, 'SetFooter' => ['{PAGENO}']]]);
     // return the pdf output as per the destination setting
     return $pdf->render();
 }
Пример #3
0
 function testEmbedHtmlImage()
 {
     // NOTE: to embed images, use <img src=""> tag but specify a path to an existing file
     $model = new \Core3\Model\Spreadsheet();
     $model->defineColumns(array('id', 'name'));
     $model->addRow(array('1', 'kalle'));
     $model->addRow(array('2', 'olle'));
     $imgFile = tempnam('/tmp', 'embedHtmlImage');
     $this->createJpeg($imgFile);
     $writer = new Pdf();
     $writer->setStartHtmlBlock('<img src="' . $imgFile . '"/><br/>');
     $writer->setEndHtmlBlock('<h2>GOODBYE</h2>');
     $data = $writer->render($model);
     unlink($imgFile);
     $reader = new \Core3\Reader\BinaryData\Document();
     $this->assertEquals(true, $reader->isRecognized($data));
     $this->assertEquals(true, $reader->isPdfData($data));
 }