Closed Mcibula closed 1 year ago
Ño, moje zistenia:
<?php
// Import FPDF and FPDI library obtained by Composer dependency manager
use \setasign\Fpdi\Fpdi;
require 'vendor/autoload.php'
// Load existing document
$pdf = new Fpdi();
$pdf->AddPage();
$pdf->setSourceFile('resources/Cestne_prehlasenie_ZPC.pdf');
$templateIdx = $pdf->importPage(1);
$pdf->useImportedPage($templateIdx);
// Set up the text style and use it to write a text in the first field
$pdf->SetFont('Courier');
$pdf->SetTextColor(0, 0, 255);
$pdf->SetXY(110, 60);
$pdf->Write(0, 'This is just a simple text');
// Export the final filled-out form
$pdf->Output('F', 'resources/output_fpdi.pdf');
Výstup output_fpdi.pdf
<?php
require 'vendor/autoload.php';
// Value mapping to field names / IDs
$fields = array(
'cislo' => '12345'
);
// Load PDF form and fill it out
$pdf = new FPDM('resources/Cestne_prehlasenie_ZPC.pdf');
$pdf->Load($fields, true);
$pdf->Merge();
// Export the final form
$pdf->Output('F', 'resources/output_fpdm.pdf');
Výstup output_fpdm.pdf
pdftk-java >= 3.3.0
pdftk-java >= 3.3.0
<?php
use mikehaertl\pdftk\Pdf;
require 'vendor/autoload.php';
// Fill form with data array
$pdf = new Pdf('resources/Cestne_prehlasenie_ZPC.pdf');
$result = $pdf->fillForm([
'cislo' => '12345 Áäéíýúô Čďňľĺšťž Ěřů'
])
->flatten()
->replacementFont('assets/fonts/DejaVuSans.ttf')
->needAppearances()
->saveAs('resources/output_pdftk.pdf');
// Check for errors
if ($result === false) {
echo $pdf->getError();
}
Výstup output_pdftk.pdf
Rozhodli sme sa pre php-pdftk
FPDI dokumentácia FPDF dokumentácia