FPDF / FDPI(在本地但不在线工作)

时间:2014-04-08 14:16:46

标签: php wordpress templates fpdf fpdi

我使用fpdf和fdpi时遇到了麻烦。

实际上我想使用pdf模板并在提交的表单上显示文本。

当地没有问题,一切正常。

但是当我在我的服务器上粘贴文件时(我在1& 1上使用wordpress),我收到以下错误

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

我真的不明白我能做些什么来修复它。我的PHP代码如下:

// 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();

如果有人能帮助我,那就太棒了。在此先感谢:)

1 个答案:

答案 0 :(得分:1)

检查目录中是否存在“cerff.pdf”:'/ homepages / 19 / d434684783 / htdocs / wp-content / themes / Avada'

也许你应该使用

中的完整路径
$pdf -> setSourceFile(<fullpath to pdf>);

另外,检查文件权限。您的主机可能会将该文件设置为只读权限。 FileZilla可以获得此文件的文件权限。

相关问题