PHP 中的 R&OS PDF(pdf 名称) [英] R&OS PDF in PHP (name of pdf)

查看:66
本文介绍了PHP 中的 R&OS PDF(pdf 名称)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人用这个函数在 PHP 中创建 PDF 吗?

anyone uses this function to create PDF in PHP?

http://www.ros.co.nz/pdf/

我需要设置这个pdf的名称,我没有找到这个选项.名称与当前页面相同;例如,如果页面是 www.myweb.com/hello.php,则名称将为 hello.pdf.我需要为每个 pdf 使用唯一名称更改此名称,因为它用于计费.

I need set the name of this pdf, and I don't find the option. The name is the same of the current page; for example if the page is www.myweb.com/hello.php the name will be hello.pdf. I need change this name with an unique name for each pdf because it is for billing.

这是代码示例:

<?php
include('class.ezpdf.php');
$pdf =& new Cezpdf('a4');
$pdf->selectFont('fonts/courier.afm');
$datacreator = array (
                    'Title'=>'Factura PDF',
                    'Author'=>'Just me',
                    'Subject'=>'Factura nº123123123',
                    'Creator'=>'Just me',
                    'Producer'=>'http://www.xxxxxxx.com'
                    );
$pdf->addInfo($datacreator);
$pdf->ezText("<b>Factura numero 123123123 </b>\n",20);
$pdf->ezText("Esta es una prueba de pdf\n",12);
$pdf->ezText("\n\n\n",10);
$pdf->ezText("<b>Fecha:</b> ".date("d/m/Y"),10);
$pdf->ezText("<b>Hora:</b> ".date("H:i:s")."\n\n",10);
$pdf->ezStream();
?>

谢谢.

推荐答案

不要使用 $pdf->ezStream()$pdf->stream()code>,使用 $pdf->output() 代替.尝试将以下代码添加到 PHP 代码的底部:

Don't use $pdf->ezStream() or $pdf->stream(), use $pdf->output() instead. Try to add following codes to the bottom of your PHP code:

header("Content-type:application/pdf");
header("Content-Disposition:attachment;filename=yourfilename.pdf");
print $pdf->output();

希望有帮助.

这篇关于PHP 中的 R&amp;OS PDF(pdf 名称)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆