2010-09-17 11 views

回答

3

我無法找到一個方法來直接打開PDF,所以我做了這個:

<?php 
// Save PDF into file 
$oPdf->save("./pdfcache/filename.pdf"); 

// Set headers 
header('Content-Type: application/pdf'); 
header('Content-Disposition: inline; filename=filename.pdf'); 
header('Cache-Control: private, max-age=0, must-revalidate'); 
header('Pragma: public'); 
ini_set('zlib.output_compression','0'); 

// Get File Contents and echo to output 
echo file_get_contents("./pdfcache/filename.pdf"); 

// Prevent anything else from being outputted 
die(); 

它並不完美,但它的工作了我。

10

使用render()方法

// Set PDF headers 
header ('Content-Type:', 'application/pdf'); 
header ('Content-Disposition:', 'inline;'); 

// Output pdf 
echo $pdf->render();