生成pdf
PDF 生成
2023-09-11 14:19:50 时间
/** * 生成pdf * @param string $html 需要生成的内容 */ function pdf($html='<h1 style="color:red">hello word</h1>'){ vendor('Tcpdf.tcpdf'); $pdf = new \Tcpdf(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // 设置打印模式 $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 001'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // 是否显示页眉 $pdf->setPrintHeader(false); // 设置页眉显示的内容 $pdf->SetHeaderData('logo.png', 60, 'baijunyao.com', '白俊遥博客', array(0,64,255), array(0,64,128)); // 设置页眉字体 $pdf->setHeaderFont(Array('dejavusans', '', '12')); // 页眉距离顶部的距离 $pdf->SetHeaderMargin('5'); // 是否显示页脚 $pdf->setPrintFooter(true); // 设置页脚显示的内容 $pdf->setFooterData(array(0,64,0), array(0,64,128)); // 设置页脚的字体 $pdf->setFooterFont(Array('dejavusans', '', '10')); // 设置页脚距离底部的距离 $pdf->SetFooterMargin('10'); // 设置默认等宽字体 $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // 设置行高 $pdf->setCellHeightRatio(1); // 设置左、上、右的间距 $pdf->SetMargins('10', '10', '10'); // 设置是否自动分页 距离底部多少距离时分页 $pdf->SetAutoPageBreak(TRUE, '15'); // 设置图像比例因子 $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { require_once(dirname(__FILE__).'/lang/eng.php'); $pdf->setLanguageArray($l); } $pdf->setFontSubsetting(true); $pdf->AddPage(); // 设置字体 $pdf->SetFont('stsongstdlight', '', 14, '', true); $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); $pdf->Output('example_001.pdf', 'I'); }
相关文章
- Spire.PDF
- 递归合并PDF按文件夹和文件名生成目录
- 金软PDF转换(x-PDFConper)
- Word处理控件Aspose.Words功能演示:使用 Android 库将 Word 文档转换为 PDF
- Linux有问必答:如何在PDF中嵌入LaTex中的所有字体
- 备战金九银十,Java 研发面试题整理 PDF,走到哪刷
- 这份阿里 P8 大佬的 1800 页计算机基础知识总结与操作系统 PDF, 安排
- 电脑端的全能扫描王:图片转文字识别、识别pdf、图片中的文字,图片提取txt
- 图片合成器,一键将目录中多个文件夹的图片转换为PDF
- Python 生成PDF生僻字无效显示的问题
- csharp: word or excel Convert to PDF
- python3参考秘籍-附PDF下载
- 浅析前端预览PDF文件方案及解决PDF.js访问远程服务器报file origin does not match viewer's的问题
- 网络工程师、软件设计师第五版pdf,25天,资源
- 【JAVA生成PDF】利用模板生成PDF
- iOS - 开发中加载本地word/pdf文档说明
- Java用iText5生成PDF
- 在VSCode中用Markdown自动生成PPT详细使用指南,支持多种风格和排版,支持ppt转为pdf等
- 功能/项目 导出pdf 包含图片 Magicodes.IE.Pdf