I want to setup FPDI in my localhost but its gives me an error.
Fatal error: Class 'FPDF' not found in C:\wamp\www\book\fpdf_tpl.php on line 20
This is what I did:
I went to download page, I downloaded 2 packs (FPDF_TPL and FPDI) and unziped them into my localhost.
Then I made a example page:
<?php
require_once('fpdf.php');
require_once('fpdi.php');
// initiate FPDI
$pdf = new FPDI();
// add a page
$pdf->AddPage();
// set the source file
$pdf->setSourceFile("PdfDocument.pdf");
// import page 1
$tplIdx = $pdf->importPage(1);
// use the imported page and place it at point 10,10 with a width of 100 mm
$pdf->useTemplate($tplIdx, 10, 10, 100);
// now write some text above the imported page
$pdf->SetFont('Helvetica');
$pdf->SetTextColor(255, 0, 0);
$pdf->SetXY(30, 30);
$pdf->Write(0, 'This is just a simple text');
pdf->Output();
I did what the site says, but I had an error:
Fatal error: Class 'FPDF' not found in C:\wamp\www\book\fpdf_tpl.php on line 20
I have searched the error codes, but I can not figure it out.
Is there anybody experienced with FPDI ?
You have to download the library in the page Download and extract it to your folder. Then the code should work. Make sure you put the correct path for require_once
.
download the fpdf lib from http://www.fpdf.org/en/download.php,
with the latest version fpdf17: require_once('your_dir/fpdf17/fpdf.php');
Add below line into your composer.
"require": {
"setasign/fpdi-fpdf": "1.6.1"
}
and update the composer using below code.
composer update setasign/fpdi-fpdf
Remove you require function lines and add below line. You will get an output.
include 'vendor/autoload.php';