【问题标题】:redirect from pdf to php从pdf重定向到php
【发布时间】:2014-07-10 07:19:14
【问题描述】:

我想将 pdf 重定向到 php .. 插入重定向到 bill_pdf.php 后。有pdf文件正在下载。下载后我想重定向回 view.php 。

谢谢

<?php
     require('../includes/db.php');
     require_once('../html2pdf/html2pdf.class.php');
   $content = "
   <html>
    <head>
        <title>Bill Generation</title>
        <style>
table,th,td
{
border:1px solid black;
border-collapse:collapse;
}
</style>
    </head>
    <body style='margin:0 auto;width:1000px'>
    <div style='width:730px;padding-left:15px'><hr/></div>

        <p style='text-align: center;  font-size: 16px;'> RECEIPT</p>
<div style='width:730px;padding-left:15px'><hr/></div>

 <p style='float:left;margin-left: 30px;font-size: 16px;'>Date: 2/3/14</p> 
<p style='font-size: 16px;margin-left:480px;margin-top:-35px'>Receipt No: 1234 </p> 
<p style='margin-left: 550px; margin-top: 40px;  font-size: 16px;'>Authorized Signatory</p></body>
</html>";
     ob_clean();
    $html2pdf = new HTML2PDF('P','A4','fr');
    $html2pdf->WriteHTML($content);
    $r=$html2pdf->Output('Bill.pdf','D');

?>

【问题讨论】:

    标签: php redirect fpdf


    【解决方案1】:

    添加这一行

    if($r) {
        header('Location: http://www.example.com/');
    }
    

    如果$r 将返回true 重定向某处..

    享受:)

    【讨论】:

      【解决方案2】:

      添加

      if($r) {
        header('Location: view.php');
      }
      

      之后

      $r=$html2pdf->Output('Bill.pdf','D');
      

      【讨论】:

      • 我不确定这是否有效。因为标题应该始终是第一个输出。
      【解决方案3】:

      您可以使用元数据来避免出现标题错误

      $r=$html2pdf->Output('Bill.pdf','D');
      if($r)
      {
         echo '<META HTTP-EQUIV="Refresh" Content="0; URL=view.php">';
      }
      else
      {
         echo '<META HTTP-EQUIV="Refresh" Content="0; URL=some_error_page.php">';
      }
      

      【讨论】:

        猜你喜欢
        • 2016-06-01
        • 1970-01-01
        • 1970-01-01
        • 2015-02-17
        • 1970-01-01
        • 2013-06-12
        • 2021-09-21
        • 1970-01-01
        • 2011-07-03
        相关资源
        最近更新 更多