首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FPDF致命错误

FPDF致命错误
EN

Stack Overflow用户
提问于 2014-07-09 03:41:10
回答 1查看 6.6K关注 0票数 1

我正在尝试测试FPDF的实现。下面是我正在测试的代码,但它一直给我错误:“致命错误:在第5行的/home4/fwall/public_html/create-press-release.php中找不到类'FPDF‘”。这是我正在调用下面代码的页面的URL。

我已经验证了FPDF的php文件是从正确的位置被要求的,而且它仍然在发生。有人能弄清楚发生了什么事吗?

代码语言:javascript
复制
require(__DIR__.'/fpdf.php'); //The fpdf folder is in my root directory.

//create a FPDF object
$pdf=new FPDF();

//set document properties
$pdf->SetAuthor('Lana Kovacevic');
$pdf->SetTitle('FPDF tutorial');

//set font for the entire document
$pdf->SetFont('Helvetica','B',20);
$pdf->SetTextColor(50,60,100);

//set up a page
$pdf->AddPage('P');
$pdf->SetDisplayMode(real,'default');

//insert an image and make it a link
//$pdf->Image('logo.png',10,20,33,0,' ','http://www.fpdf.org/');

//display the title with a border around it
$pdf->SetXY(50,20);
$pdf->SetDrawColor(50,60,100);
$pdf->Cell(100,10,'FPDF Tutorial',1,0,'C',0);

//Set x and y position for the main text, reduce font size and write content
$pdf->SetXY (10,50);
$pdf->SetFontSize(10);
$pdf->Write(5,'Congratulations! You have generated a PDF.');

//Output the document
$pdf->Output('example1.pdf','I'); 
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-09 03:54:04

这一行:

代码语言:javascript
复制
require('http://siteurlredacted.com/fpdf/fpdf.php');

可能不会做你想做的事。请求将使远程服务器“执行”fpdf.php,返回一个空白页,您的脚本将包含一个空文件。这就是为什么它找不到要加载的类的原因。

您应该下载FPDF并将该文件放到您的文件系统中,在那里它可以在没有HTTP请求的情况下访问您的脚本。您可以尝试将fpdf.php放入您的项目中。

希望这能有所帮助。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24645024

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档