0

I am using Codeignighter, FPDF and FPDI to Amend a PDF to be emailed to a client.

Using the basic example give by FPDI I can get my code to work perfectly on localhost (standalone php file, no codeignighter) however when i put the same file onto my server i get the following warning and error.

Severity: Warning

Message: fopen(PDF.pdf): failed to open stream: No such file or directory

Filename: PdfParser/StreamReader.php

My code:

require ('fpdf182/fpdf.php') ;
require ('setasign/Fpdi/autoload.php') ;
use setasign\Fpdi\Fpdi;

$pdf = new Fpdi();

$pdf->AddPage();

$pdf->setSourceFile('PDF.pdf');

$tplIdx = $pdf->importPage(1);

$pdf->useTemplate($tplIdx, 10, 10, 100);

$pdf->SetFont('Helvetica');
$pdf->SetTextColor(255, 0, 0);
$pdf->SetXY(30, 30);
$pdf->Write(0, 'This is just a simple text');

$pdf->Output('I', 'generated.pdf');```

Thank you for your time and thank you in advance

1 Answers1

0

Did you check the permission of the folder that is supposed to save the pdf file? Your webserver runs as some user and this user should have write permissions.

  • Permissions look good. I have a feeling that it is something to do with my htacess as I cant type a direct url in. everything comes up with 404 even though i know there is a file there. – user2213713 Feb 15 '21 at 12:15