如何在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 AJAX 投票问题 一个简单的问题大家,帮忙看看 ADODB+Smarty如何循环出库中的类别及各类别下面的文章 怎样编程实现本地图片上传时保存到FTP?(PHP) 讨论线下生成静态页面的目录结构的问题. 一个提交留言的模板提交后老是显示点击下载保存的页面 急切求助,在线等:php实现文件下载后,该页面的动态内容全部锁死点击无效. 请问我应该怎样使用mysql-front 3.2啊? 汉字显示不正确? 小问题哦 求正则表达式:匹配非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