This commit is contained in:
2022-01-13 18:41:03 +01:00
commit 0fb9f639da
159 changed files with 13183 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
<?php declare(strict_types = 1);
namespace App\Modules\Pdf\Home;
use App\Modules\Base\BasePresenter;
use Contributte\PdfResponse\PdfResponse;
use Nette\Bridges\ApplicationLatte\Template;
class HomePresenter extends BasePresenter
{
/** @inject */
public PdfResponse $pdfResponse;
private function createPdf(): PdfResponse
{
/** @var Template $template */
$template = $this->createTemplate();
$template->setFile(__DIR__ . '/../../../resources/pdf/example.latte');
$template->title = 'Contributte PDF example';
$this->pdfResponse->setTemplate($template->renderToString());
$this->pdfResponse->documentTitle = 'Contributte PDF example'; // creates filename 2012-06-30-my-super-title.pdf
$this->pdfResponse->pageFormat = 'A4-L'; // wide format
$this->pdfResponse->getMPDF()->SetFooter('|Contributte PDF|'); // footer
return $this->pdfResponse;
}
public function actionViewPdf(): void
{
$pdf = $this->createPdf();
$pdf->setSaveMode(PdfResponse::INLINE);
$this->sendResponse($pdf);
}
public function actionDownloadPdf(): void
{
$pdf = $this->createPdf();
$pdf->setSaveMode(PdfResponse::DOWNLOAD);
$this->sendResponse($pdf);
}
}

View File

@@ -0,0 +1,34 @@
{block #content}
<div id="banner">
<h1 n:block=title>Contributte PDF example</h1>
</div>
<div id="content">
<h2>Welcome in example of using contributte/pdf.</h2>
<a n:href="Home:viewPdf" target="_blank">View generated PDF</a>
<br><br>
<a n:href="Home:downloadPdf" target="_blank">Download generated PDF</a>
<p></p>
</div>
<style>
html { font: normal 18px/1.3 Georgia, "New York CE", utopia, serif; color: #666; -webkit-text-stroke: 1px rgba(0,0,0,0); overflow-y: scroll; }
body { background: #3484d2; color: #333; margin: 2em auto; padding: 0 .5em; max-width: 800px; min-width: 320px; }
a { color: #006aeb; padding: 3px 1px; }
a:hover, a:active, a:focus { background-color: #006aeb; text-decoration: none; color: white; }
#banner { border-radius: 12px 12px 0 0; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAB5CAMAAADPursXAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAGBQTFRFD1CRDkqFDTlmDkF1D06NDT1tDTNZDk2KEFWaDTZgDkiCDTtpDT5wDkZ/DTBVEFacEFOWD1KUDTRcDTFWDkV9DkR7DkN4DkByDTVeDC9TDThjDTxrDkeADkuIDTRbDC9SbsUaggAAAEdJREFUeNqkwYURgAAQA7DH3d3335LSKyxAYpf9vWCpnYbf01qcOdFVXc14w4BznNTjkQfsscAdU3b4wIh9fDVYc4zV8xZgAAYaCMI6vPgLAAAAAElFTkSuQmCC); }
h1 { font: inherit; color: white; font-size: 50px; line-height: 121px; margin: 0; padding-left: 4%; background: url(https://files.nette.org/images/logo-nette@2.png) no-repeat 95%; background-size: 130px auto; text-shadow: 1px 1px 0 rgba(0, 0, 0, .9); }
@media (max-width: 600px) {
h1 { background: none; font-size: 40px; }
}
#content { background: white; border: 1px solid #eff4f7; border-radius: 0 0 12px 12px; padding: 10px 4%; overflow: hidden; }
h2 { font: inherit; padding: 1.2em 0; margin: 0; }
img { border: none; float: right; margin: 0 0 1em 3em; }
</style>

View File

@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>{ifset title}{include title|stripHtml} | {/ifset}Nette Web</title>
</head>
<body>
<div n:foreach="$flashes as $flash" n:class="flash, $flash->type">{$flash->message}</div>
{include content}
{block scripts}
<script src="https://nette.github.io/resources/js/3/netteForms.min.js"></script>
{/block}
</body>
</html>