本文介绍了如何使用php渲染pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们有一些PDF文件,而不是直接链接到文件,我们希望它通过php呈现,以便只有经过身份验证的用户才能下载pdf文件.因此,我们不需要将文件路径提供给用户.
We have some PDF files and instead of giving direct link to to file, we want it to render through php so that only authenticated users are able to download the pdf file. Thus we dont need to give filepath to user.
有可能吗?
Mangesh
推荐答案可以,下面是一个示例:
You can, here is a sample:
<?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); ?>更多推荐
如何使用php渲染pdf文件
发布评论