0

I have troubles using fpdf and fdpi.

In fact i want to use a pdf template and display text on it from a submitted form.

There are no problmes in local, everything works fine.

But when i paste files on my server (i use wordpress on 1&1), i get the following errors

Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Cannot open cerff.pdf !' in /homepages/19/d434684783/htdocs/wp-content/themes/Avada/pdf_parser.php:192 Stack trace: #0 
/homepages/19/d434684783/htdocs/wpcontent/themes/Avada/fpdi_pdf_parser.php(71): pdf_parser->__construct('cerff.pdf') 
#1 /homepages/19/d434684783/htdocs/wp-content/themes/Avada/fpdi.php(128): fpdi_pdf_parser->__construct('cerff.pdf') 
#2 /homepages/19/d434684783/htdocs/wp-content/themes/Avada/fpdi.php(108): FPDI->_getPdfParser('cerff.pdf') 
#3 /homepages/19/d434684783/htdocs/wp-content/themes/Avada/cerfa.php(8): FPDI->setSourceFile('cerff.pdf') 
#4 /homepages/19/d434684783/htdocs/wp-includes/template-loader.php(74): include('/homepages/19/d...') 
#5 /homepages/19/d434684783/htdocs/wp-blog-header.php(16): require_once('/homepages/19/d...') 
#6 /homepages/19/d434684783/htdocs/index.php(17): require('/homepages/19/d...') 
#7 {main} thrown in /homepages/19/d434684783/htdocs/wp-content/themes/Avada/pdf_parser.php on line 192

I don't really understand what i can do to fix it. My PHP code is the following :

// Template Name: generationCerfa
include('fpdf.php'); 
include('fpdi.php'); 

// initiate FPDI 
$pdf = new FPDI();
$pdf -> setSourceFile('cerff.pdf');
$tplIdx = $pdf -> importPage(1);
$size = $pdf->getTemplateSize($tplIdx);
$pdf -> AddPage();
$pdf ->useTemplate($tplIdx, 0,0,0,0, TRUE);
$pdf -> SetFont('Arial');
$pdf -> SetTextColor(0, 0, 0);

$pdf -> Output();

If anyone can help me it would be amazing. Thanks in advance :)

Aloys Fortier
  • 21
  • 2
  • 7
  • I precise that i've try the same code on my server root, and it works as well as in local ... So i think it's a wordpress problem , but i can't get what ... :/ – Aloys Fortier Apr 08 '14 at 14:33

1 Answers1

1

check if "cerff.pdf" exists in directory: '/homepages/19/d434684783/htdocs/wp-content/themes/Avada'

Maybe you should use the fullpath in

$pdf -> setSourceFile(<fullpath to pdf>);

Also, check the file permissions. Your host may put the file with readonly permissions. FileZilla can what file permissions for this file are.

779IDEAS
  • 301
  • 1
  • 14