在当前浏览器页面IE浏览器中直接下载PDF

问题描述

我正在使用PHP创建强制在Internet Explorer当前页面中下载PDF文件。 PDF消息中显示错误Format error: Not a PDF or corrupted.

下面是我的示例代码

<?PHP
header("Content-type: application-download");
header("Content-Length: $size");
header("Content-disposition: attachment; filename=MyPDF.pdf");
header("Content-transfer-encoding: binary");

?>
<html xmlns="http://www.w3.org/1999/xhtml">

<body>
    <form id="form1">
    <div id="dvContainer">
        This content needs to be printed.
    </div>
    </form>
</body>
</html>

PDF输出如下图所示:

pdf

我希望PDF中的预期结果如下图所示:

pdf 2

希望有人可以指导我哪里我做错了。谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)