【发布时间】:2017-06-25 10:51:25
【问题描述】:
我创建了一个简历生成器应用程序。用户输入所有必需的详细信息,我将所有详细信息存储在数据库中。然后我获取这些记录并将其显示在不同的模板中。我创建了 3 个模板。现在我想以 pdf 格式下载和以 docx 格式下载两个下载按钮。一旦用户单击任何按钮文件,将以他们选择的格式下载。 pdf 或 docx。
是否可以在codeigniter中实现?
我用过 Tcpdf
控制器代码是
the code written in controller download $this - > load - > library("Pdf");
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set auto page breaks
$pdf - > SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf - > setImageScale(PDF_IMAGE_SCALE_RATIO);
// Add a page
// This method has several options, check the source code documentation for more information.
$pdf - > AddPage();
// Set some content to print
$html = $this - > load - > view('resume/res_template1_view', array('left_sidebar' => 'sidebar/left_sidebar', ' right_sidebar' => 'sidebar/right_sidebar'), $data, TRUE);
// Print text using writeHTMLCell()
$pdf - > writeHTML($html, 0, 0, '', '', 0, 1, 0, true, '', true);
//$pdf->writeHTML($html, true, false, true, false, '');
// Close and output PDF document
// This method has several options, check the source code documentation for more information.
$pdf - > Output('resume.pdf', 'D');
【问题讨论】:
-
谷歌搜索类似“php html2pdf”的内容。关于
.docx文件PHPOffice/PHPWord可能是您的选择。 -
你也可以使用parall.ax/products/jspdf这个。非常有据可查。
-
您可以使用Mpdf
https://davidsimpson.me/2013/05/19/using-mpdf-with-codeigniter/或http://www.w3school.info/2016/02/08/convert-html-to-pdf-in-codeigniter-using-mpdf/
标签: codeigniter pdf