【问题标题】:How to render pdf file by using php如何使用 php 渲染 pdf 文件
【发布时间】:2014-03-01 05:55:03
【问题描述】:

我们有一些 PDF 文件,而不是直接链接到文件,我们希望它通过 php 呈现,以便只有经过身份验证的用户才能下载 pdf 文件。因此我们不需要给用户文件路径。

有可能吗?

曼格什

【问题讨论】:

    标签: php pdf render


    【解决方案1】:

    你可以,这是一个示例:

    <?php
    $file = './path/to/the.pdf';
    $filename = 'You dont know where I am.pdf';
    
    header('Content-type: application/pdf');
    header('Content-Disposition: inline; filename="' . $filename . '"');
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: ' . filesize($file));
    header('Accept-Ranges: bytes');
    
    @readfile($file);
    ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-28
      • 2010-10-05
      相关资源
      最近更新 更多