Skip to content

Commit

Permalink
Logos on PDF (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhaniot authored and spapad committed Oct 24, 2017
1 parent 4ffa7e8 commit c5dc4b8
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
11 changes: 6 additions & 5 deletions controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,10 @@ public function actionPrintApplications($applicantId = null)
$data[$j]['user'] = $users[$j];
$data[$j]['provider'] = $provider;
}

$content = $this->renderPartial('../application/print', ['data' => $data]);
// setup kartik\mpdf\Pdf component
$actionlogo = "file:///" . realpath(dirname(__FILE__). '/../web/images/logo.jpg');
$pdelogo = "file:///" . realpath(dirname(__FILE__). '/../web/images/pdelogo.jpg');
$content = $this->renderPartial('../application/print', ['data' => $data]);
// setup kartik\mpdf\Pdf component
$pdf = new Pdf([
'mode' => Pdf::MODE_UTF8,
'format' => Pdf::FORMAT_A4,
Expand All @@ -221,8 +222,8 @@ public function actionPrintApplications($applicantId = null)
'cssInline' => '.kv-heading-1{font-size:18px}',
'options' => ['title' => 'Περιφερειακή Διεύθυνση Πρωτοβάθμιας και Δευτεροβάθμιας Εκπαίδευσης Κρήτης'],
'methods' => [
'SetHeader' => ['Περιφερειακή Διεύθυνση Πρωτοβάθμιας και Δευτεροβάθμιας Εκπαίδευσης Κρήτης'],
'SetFooter' => ['Σελίδα: {PAGENO} από {nb}'],
'SetHeader' => ['<img src=\'' . $pdelogo . '\'>'],
'SetFooter' => ['<img src=\'' . $actionlogo . '\'>Σελίδα: {PAGENO} από {nb}'],
]
]);

Expand Down
8 changes: 5 additions & 3 deletions controllers/ApplicationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ public function actionMyApplication($printMode = 0)
$content = $this->renderPartial('print', [
'data' => $data,
]);


$actionlogo = "file:///" . realpath(dirname(__FILE__). '/../web/images/logo.jpg');
$pdelogo = "file:///" . realpath(dirname(__FILE__). '/../web/images/pdelogo.jpg');
// setup kartik\mpdf\Pdf component
$pdf = new Pdf([
'mode' => Pdf::MODE_UTF8,
Expand All @@ -131,8 +133,8 @@ public function actionMyApplication($printMode = 0)
'cssInline' => '.kv-heading-1{font-size:18px}',
'options' => ['title' => 'Περιφερειακή Διεύθυνση Πρωτοβάθμιας και Δευτεροβάθμιας Εκπαίδευσης Κρήτης'],
'methods' => [
'SetHeader' => ['Περιφερειακή Διεύθυνση Πρωτοβάθμιας και Δευτεροβάθμιας Εκπαίδευσης Κρήτης'],
'SetFooter' => ['Σελίδα: {PAGENO} από {nb}'],
'SetHeader' => ['<img src=\'' . $pdelogo . '\'>'],
'SetFooter' => ['<img src=\'' . $actionlogo . '\'>Σελίδα: {PAGENO} από {nb}'],
]
]);

Expand Down
3 changes: 2 additions & 1 deletion views/application/print.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
echo "<pagebreak />";
}

?>
?>
<br /><br /><br />
<h3 style="text-align: center;"><?= Html::encode($this->title) ?></h3>
<table style="border: 1px solid grey; width: 100%;border-spacing: 10px; padding: 5px; background-color: #efefef;">
<tr>
Expand Down
6 changes: 5 additions & 1 deletion views/application/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,9 @@
?>
</tbody>
</table>

<div style="display: block; margin: auto; width:50%;">
<?php
$actionlogo = realpath(dirname(__FILE__). '/../../web/images/logo.jpg');
echo Html::img('images/logo.jpg') ?>
</div>
</div>
Binary file added web/images/logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/images/pdelogo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c5dc4b8

Please sign in to comment.