我正在使用html2pdf类来生成pdf。在我的问题中,它为html代码生成pdf,但它没有给对话框提供下载该pdf的选项。请帮我的忙,下面是我的建议。
<?php
ob_start();
include(dirname(__FILE__).'/res/pdf_demo.php');
$content = ob_get_clean();
// conversion HTML => PDF
require_once(dirname(__FILE__).'/../html2pdf.class.php');
try
{
$html2pdf = new HTML2PDF('P','A4', 'fr', false, 'ISO-8859-15');
$html2pdf->pdf->SetDisplayMode('fullpage');
$html2pdf->writeHTML($content, isset($_GET['vuehtml']));
$html2pdf->Output('pdf_demo.pdf');
}
catch(HTML2PDF_exception $e) { echo $e; }
?>发布于 2010-10-06 14:44:20
要从您的浏览器提供下载,您需要添加被附件的标题...
header("Content-Disposition: attachment; filename=sample.pdf");在页面的开头添加上面的代码,然后继续进行html2pdf转换。
发布于 2013-05-20 17:03:07
从文档中,方法输出
/**
* Send the document to a given destination: string, local file or browser.
* Dest can be :
* I : send the file inline to the browser (default). The plug-in is used if available. The name given by name is used when one selects the "Save as" option on the link generating the PDF.
* D : send to the browser and force a file download with the name given by name.
* F : save to a local server file with the name given by name.
* S : return the document as a string. name is ignored.
* FI: equivalent to F + I option
* FD: equivalent to F + D option
* true => I
* false => S
*发布于 2015-06-25 12:37:04
将此行$html2pdf->Output('pdf_demo.pdf');更改为$html2pdf->Output('pdf_demo.pdf', 'D');,它将强制浏览器自动下载pdf文件。
https://stackoverflow.com/questions/3870006
复制相似问题