douguachi0056 2012-02-07 00:41
浏览 164
已采纳

使用tcpdf库覆盖pdf文件

I am trying to write pdf file using TCPDF open source liberay.

i use following code..

$html = <<<EOD
$prod
EOD;

$pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);

$pdf->Output('pricepdf.pdf', 'FD');

I have dumped $html, and its okay.

now, the problem is with writing pdf file, I can't write the file .either no error is displayed. Onething, i should clear that, a file with same name is already exists in the given folder.

What i want is, to ovewrite 'pricepdf.pdf' file everytime, i run the script

Please guide me regarding this, Is this overwrite problem? or something else is creating problem? I am stuck at the point...

  • 写回答

1条回答 默认 最新

  • dongqiao6445 2012-02-07 00:52
    关注

    If the script is not able to overwrite the file then you could check whether file exists and remove it.

    if (file_exists('pricepdf.pdf')) unlink('pricepdf.pdf');
    $pdf->Output('pricepdf.pdf', 'FD');
    

    Turn on errors display to see if there is a problem with access to the file.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错