小编Oli*_*ier的帖子

用于 PDF.js 的 PHP 标头逐步加载和显示

有谁知道如何在 PHP 输出 PDF 文件时让 PDF.js 逐步加载和显示页面?直接调用时,PDF 文件加载良好并逐渐显示,但当 PHP 处理同一个 PDF 文件的输出时,PDF.js 会在显示第一页之前等待整个文件加载完毕。我尝试了不同的标题,例如这些没有成功:

$file = 'big.pdf';
$filename = 'fakefilename.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);
Run Code Online (Sandbox Code Playgroud)

在此先感谢您的帮助。

在@Rob 发表评论后编辑:以下是来自网络浏览器的日志:

Accept-Ranges   0-23822222
Cache-Control   no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection  Keep-Alive
Content-Length  23822222
Content-Range   bytes 0-23822221/23822222
Content-Type    application/pdf
Date    Mon, 23 Jun 2014 13:06:33 GMT
Expires Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive  timeout=15, max=99
Pragma  no-cache
Server  Apache/2.2.16 (Debian)
X-Powered-By …
Run Code Online (Sandbox Code Playgroud)

php pdf.js

1
推荐指数
1
解决办法
1989
查看次数

标签 统计

pdf.js ×1

php ×1