我有一个新的挑战,将html发票保存到我已经完成的pdf中,但也希望在保存后将其流式传输到屏幕上。我用来转换的代码是
$cur_dir = dirname(__FILE__);
require_once($cur_dir.'/dompdf/dompdf_config.inc.php');
class pdfCreator {
private $curDir;{
public function __construct() {
global $cur_dir;
$this->curDir = $cur_dir;
}
private function getHtml() {
ob_start();
include($this->curDir . '/template.php');
$retStr = ob_get_contents();
ob_end_clean();
return $retStr;
}
public function getPdf() {
$html = $this->getHtml();
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$output = $dompdf->output();
$pdfFileName = $this->curDir.'/invoice.pdf';
file_put_contents($pdfFileName, $output);
}
}
$pdfCreator = new pdfCreator();
$pdfCreator->getPdf();
}
如果有人能帮我讲述如何在屏幕上播放它将会有很大的帮助。
谢谢
答案 0 :(得分:0)
类似的事情:
$size = filesize($pdfFileName);
header("Content-length: $size");
header("Content-type: application/pdf");
header("Content-Disposition: inline; filename=$pdfFileName");
readfile($pdfFileName);
exit();