用PHP在浏览器中打开PDF [英] open PDF in browser with PHP
本文介绍了用PHP在浏览器中打开PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在做:
I am doing:
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="the.pdf"');
header('Content-Length: ' . filesize($file));
@readfile($file);
,它工作正常。 PDF会在浏览器中打开。
and it works fine. The PDF opens in the browser.
我可以在if-then-else之前做些什么吗?我试过了,并且我得到了原始PDF
Can I do an if-then-else before? I tried and I get raw PDF
%PDF-1.2 9 0 obj << /Type/Font /Subtype/Type1 /Name/F1 /FontDescriptor 8 0
那么 - 否则更改标题?
Why is the if-then-else changing the headers?
谢谢。
推荐答案
如果你发布了你的if-then-else代码,那将会很有帮助。我的猜测是在输出标题之前你有一些空白输出。
It would be helpful if you posted exactly what is your if-then-else code. My guess is you have some whitespace output before the headers are outputted.
这篇关于用PHP在浏览器中打开PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文