首页 > 解决方案 > 我该如何重定向?dompdf 生成发票,但未进行重定向

问题描述

我该如何重定向?dompdf 生成发票但不进行重定向,生成 pdf 文件后如何重定向?生成 pdf 文件后,页面仅变为空白并且不执行任何操作。

<?php

    session_start();
    if(isset($_SESSION['USER_ID'])){
        $USER_ID = $_SESSION['USER_ID'];    
    }else{
        header('location:../eProject/login.php');
    }

    // Include autoloader 
    require_once 'vendor/dompdf/autoload.inc.php'; 

    // Reference the Dompdf namespace 
    use Dompdf\Dompdf; 

    // Instantiate and use the dompdf class 
    $dompdf = new Dompdf();

    ?>


    <?php
    $conn = oci_connect('EXAMPLE', 'utsav', '//localhost/xe'); 
    // Load content from html file 
    $html = file_get_contents("invoice.html"); 
    $dompdf->loadHtml($html); 
    $file_name = 'invoice' . '.pdf';

    // (Optional) Setup the paper size and orientation 
    $dompdf->setPaper('A4', 'landscape'); 

    // Render the HTML as PDF 
    $dompdf->render();
    $file = $dompdf->output();
    file_put_contents($file_name, $file);

    // Output the generated PDF (1 = download and 0 = preview) 
    $dompdf->stream("Cleckhuddersfax", array("Attachment" => 1));
?>

<script type="text/javascript">location.replace('index.php')</script>

标签: javascriptphphtml

解决方案


推荐阅读