<?php
$html = file_get_contents("./2.html");
$fileName = 'ceshi';
/**
* 将html文件转换为pdf
* @param unknown $html html文件 地址 如:"http://10.10.10.80/YunJiJiuZhuFuWu-Server/pages/app/2.html"
* @param string $title 标题
* @param unknown $fileName 文件名称
*/
function pdfRender($html, $title = '标题',$fileName)
{
if(!empty(html)){
$html = file_get_contents($html);
}
// require_once(dirname(__FILE__).'/tcpdf_autoconfig.php');
require_once('./tcpdf/tcpdf.php');
/*新建一个pdf文件:
Orientation:orientation属性用来设置文档打印格式是“Portrait”还是“Landscape”。 Landscape为横式打印,Portrait为纵向打印
Unit:设置页面的单位。pt:点为单位,mm:毫米为单位,cm:厘米为单位,in:英尺为单位
Format:设置打印格式,一般设置为A4
Unicode:为true,输入的文本为Unicode字符文本
Encoding:设置编码格式,默认为utf-8
Diskcache:为true,通过使用文件系统的临时缓存数据减少RAM的内存使用。 */
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT,true, 'UTF-8', false);
//设置文件信息
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor("jmcx");
$pdf->SetTitle($title);
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
//删除预定义的打印 页眉/页尾
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
//设置默认等宽字体
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
/*设置页面边幅:
Left:左边幅
Top:顶部边幅
Right:右边幅
Keepmargins:为true时,覆盖默认的PDF边幅。 */
excel 转图片
最新推荐文章于 2025-08-05 10:10:03 发布
