代码之家  ›  专栏  ›  技术社区  ›  zod

Zend PDF-要打开而不是保存吗

  •  2
  • zod  · 技术社区  · 14 年前

    创建后保存

    我想打开它而不是保存。

    当我直接访问url时

    2 回复  |  直到 14 年前
        1
  •  4
  •   Stephen RC    13 年前

    我找不到直接打开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();
    

    这并不完美,但对我来说很合适。

        2
  •  11
  •   Jordi    12 年前

    // Set PDF headers
    header ('Content-Type:', 'application/pdf');
    header ('Content-Disposition:', 'inline;');
    
    // Output pdf
    echo $pdf->render();