如何在PHP虚拟主机上创建PDF? 只要简单的代码示例就可以。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 PHP手册上的例子http://www.php.net/manual/en/pdf.examples-basic.php<?phptry { $p = new PDFlib(); /* open new PDF file; insert a file name to create the PDF on disk */ if ($p->begin_document("", "") == 0) { die("Error: " . $p->get_errmsg()); } $p->set_info("Creator", "hello.php"); $p->set_info("Author", "Rainer Schaaf"); $p->set_info("Title", "Hello world (PHP)!"); $p->begin_page_ext(595, 842, ""); $font = $p->load_font("Helvetica-Bold", "winansi", ""); $p->setfont($font, 24.0); $p->set_text_pos(50, 700); $p->show("Hello world!"); $p->continue_text("(says PHP)"); $p->end_page_ext(""); $p->end_document(""); $buf = $p->get_buffer(); $len = strlen($buf); header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=hello.pdf"); print $buf;}catch (PDFlibException $e) { die("PDFlib exception occurred in hello sample:\n" . "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " . $e->get_errmsg() . "\n");}catch (Exception $e) { die($e);}$p = 0;?> 我的是PHP4,你给的答复上下两个都试过了,出来是空白屏幕。 为什么不用PHP 5 呢? PHP是免费的啊。 www.php.net PHP4上安装pdf扩展,参看php手册http://www.php.net/manual/en/pdf.installation.php 可以用 开源的tcpdf 去创建pdf 官方pdf 要安装扩展 进行配置 PHP 4版本的服务器竟然还可以卖出去,,,,,买之前最好跟空间商说定配置的。 求助php Smarty模板使用kindeditor编译器防止字符转义 急寻网站开发高手! pdo是不是自动进行连接优化的? 在MYSQL 中怎样正则IMG标记 Smarty模板的问题,出现奇怪的东西~~~ 如何得到上传图片的宽高的尺寸呢? php能不能调用自己写的c语言库 ? PHP如何才能实现无组件在线发送附件? 一个关于字符串截取的问题 哪里有关于PHP+ORACLE和免费东东呀! 求正则表达式:匹配非XX开头,非XX结尾,中间匹配 PHP页面嵌入显示一个HTML页面,不用框架,如何显示
$p = new PDFlib(); /* open new PDF file; insert a file name to create the PDF on disk */
if ($p->begin_document("", "") == 0) {
die("Error: " . $p->get_errmsg());
} $p->set_info("Creator", "hello.php");
$p->set_info("Author", "Rainer Schaaf");
$p->set_info("Title", "Hello world (PHP)!"); $p->begin_page_ext(595, 842, ""); $font = $p->load_font("Helvetica-Bold", "winansi", ""); $p->setfont($font, 24.0);
$p->set_text_pos(50, 700);
$p->show("Hello world!");
$p->continue_text("(says PHP)");
$p->end_page_ext(""); $p->end_document(""); $buf = $p->get_buffer();
$len = strlen($buf); header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in hello sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
为什么不用PHP 5 呢? PHP是免费的啊。 www.php.net
http://www.php.net/manual/en/pdf.installation.php