eOSP2/app/Http/Controllers/documentOverlayController.php

51 lines
1.4 KiB
PHP
Raw Normal View History

2020-03-25 00:20:45 +01:00
<?php
namespace App\Http\Controllers;
use Codedge\Fpdf\Fpdf\Fpdf;
use Illuminate\Http\Request;
use setasign\Fpdi\Fpdi;
class documentOverlayController extends Controller
{
//
public function testPdf($fireFighterID){
// initiate FPDI
$pdf = new Fpdi();
// set the source file
$pageCount = $pdf->setSourceFile("../app/Http/Controllers/documentTemplates/a.pdf");
// import page 1
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
// import a page
$templateId = $pdf->importPage($pageNo);
// get the size of the imported page
$size = $pdf->getTemplateSize($templateId);
// create a page (landscape or portrait depending on the imported page size)
if ($size[0] > $size[1]) {
$pdf->AddPage('L', array($size[0], $size[1]));
} else {
$pdf->AddPage('P', array($size[0], $size[1]));
}
$pdf->useTemplate($templateId);
if($pageNo == 1){
$str = iconv('UTF-8', 'cp1250', 'zazółcić gęślą jaźń');
$xyz = iconv('UTF-8', 'cp1250', $fireFighterID);
// now write some text above the imported page
$pdf->SetFont('times');
$pdf->SetTextColor(255, 0, 0);
$pdf->SetXY(30, 30);
$pdf->Write(0, $xyz);
}
}
$pdf->Output();
}
}