【发布时间】:2014-03-21 09:09:39
【问题描述】:
我正在尝试制作一个电子商务网站,用户将在其中单击链接并制作发票,并应在客户端下载我在 html 中创建的发票的 pdf 文件,问题是我使用了这段代码,它与 ms word 作为 .doc 文档一起使用,但我想对 pdf 不工作做同样的事情,代码粘贴在下面
// the code to download invoice as word document, it's working
<?php
header('Content-type: application/vnd.ms-word');
header('Content-Disposition: attachment;Filename='.$result->tracking_number.'.doc');
?>
<!DOCTYPE html>
<html>
<head>
但与此代码相同的代码不适用于 pdf :(
<?php
header('Content-type: application/pdf');
header('Content-Disposition: attachment;Filename='.$result->tracking_number.'.pdf');
?>
<!DOCTYPE html>
<html>
<head>
下载的pdf显示格式已损坏,该怎么办,我必须尽快完成:((
【问题讨论】:
-
你应该使用像 mpdf 或 TCPDF 这样的 pdf 库
-
我也试过了,但没用:(
-
什么不起作用?你试过什么?我们可以看看一些代码吗?
-
顺便说一句,因为你使用 codeigniter 看到这个页面:github.com/EllisLab/CodeIgniter/wiki/…
-
我遵循了上述文章中的所有内容,但是下载了一个 pdf 文件,但是当我打开它时说它已损坏:(
标签: php html codeigniter pdf