javascript - 我该如何重定向?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>
解决方案
推荐阅读
- python - 为什么 [x] * n 在 Python 中比 [x for _ in range(n)] 使用更少的内存?
- ios - 在 SwiftUI 中应用cornerRadius 或clipShape 时,iOS Widget 崩溃
- spring-boot - 如何检查springboot JPA的表中是否已经存在记录?
- javascript - 在同一元素上的 addEventListener() 之后添加 jQuery .click()
- excel - 根据多列条件将单元格从一个工作表复制到另一个工作表
- html - HTML/CSS - 将多个文本元素连接在一起
- apache - 如何重写 url 以使用 Apache 附加标头
- python-3.x - python 3 pandas数据帧的迭代以外的条件和技术
- java - 我们可以跳过 Java8 Streams
- sql - 使用索引进行 SQL Select 查询优化