8

DOMPDFで同時に2つのことを行う必要があります。

以下を一緒に行う必要があります - これは可能ですか?

//print the pdf file to the screen for saving
$dompdf->stream("pdf_filename_".rand(10,1000).".pdf", array("Attachment" => false));
//save the pdf file on the server
file_put_contents('/home/stsnew/public_html/pdf/file.pdf', $dompdf->output()); 

$dompdf->streamとが別々に/個別に実行された場合、上記は正常に機能します$dompdf->output()が、上記のようにそれらを一緒に実行しようとすると、クラッシュします。

ヘルプ/アドバイスをいただければ幸いです。

4

2 に答える 2

27

最初にpdfをファイルとして作成してから、作成したファイルをストリーミングして戻してください。

$file_to_save = '/home/stsnew/public_html/pdf/file.pdf';
//save the pdf file on the server
file_put_contents($file_to_save, $dompdf->output()); 
//print the pdf file to the screen for saving
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="file.pdf"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file_to_save));
header('Accept-Ranges: bytes');
readfile($file_to_save);
于 2011-10-12T16:34:12.333 に答える