zoukankan      html  css  js  c++  java
  • TCPDF说明文档

    TCPDF说明文档

    一、首先调用TCPDF文件

    require_once('tcpdf.php');

    二、实例化TCPDF类 页面方向(P =肖像,L =景观)、测量(mm)、页面格式

     $pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false); 

    三、设置文档信息

    设置文档信息----文件创作者

    $pdf->SetCreator('Helloweba');
    
    $pdf->SetAuthor('yueguangguang');
    
    $pdf->SetTitle('Welcome to helloweba.com!');
    
    $pdf->SetSubject('TCPDF Tutorial');
    
    $pdf->SetKeywords('TCPDF, PDF, PHP');

    四、设置默认标题数据

    $pdf->SetHeaderData(PDF_HEADER_LOGO,PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 038', PDF_HEADER_STRING);

    五、设置页眉和页脚信息

    //Page header
            public function Header() {
                // Logo
                $image_file = K_PATH_IMAGES.'bl_logo.png';
                $this->Image($image_file, 10, 5, 8, '', 'PNG', '', 'T', false, 300, '', false, false, 0, false, false, false);
                // Set font
                $this->SetFont('stsongstdlight', 'B', 10);
                // Title
                $this->Write(8, '山东保蓝环保');
                $this->Cell(0, 0, '技术方案', 0, false, 'R', 0, '', 0, false, 'M', 'M');
            }
    
            // Page footer
            public function Footer() {
                // Position at 15 mm from bottom
                $this->SetY(-15);
                // Set font
                $this->SetFont('stsongstdlight', 'I', 8);
                // Page number
                $this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
            }

    六、设置字体

    $pdf->SetFont('stsongstdlight', '', 12);

    七、添加一个页面

    $pdf->AddPage();

     

    八、该方法从当前位置打印文本

          (行高,文本变量,通过AddLink()返回的URL或标识符,背景画,允许中心或对齐文本,如果正确设置光标底部的线,否则设置游标的行,字体延伸模式,如果真的只打印第一行并返回剩余的字符串,如果真正的字符串是一行的开始,最大高度,补白)

         $pdf->Write(0,$str1,'', 0, 'L', true, 0, false, false, 0);

     

    九、安全密码设置

    $user_pass用户密码、$owner_pass 所有者密码、$mode加密强度0 = RC4 40位;1 = RC4 128位;2 = AES 128位;3 = AES 256位。、 $pubkeys数组包含公钥证书(“c”)的接受者和权限(“p”)$pdffile['password']

    $pdf->SetProtection($permissions = array('print', 'modify', 'copy', 'annot-forms', 'fill-forms', 'extract', 'assemble', 'print-high'), $user_pass = '123456', $owner_pass = null, $mode = 0, $pubkeys = null );

     

    十、输出PDF

     默认是I:在浏览器中打开,D:下载,F:在服务器生成pdf ,S:只返回pdf的字符串,个人感觉无实在意义

    $pdf->Output('t.pdf', 'I');

     

    扩展--输入文字:

    单行文本
    Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=0, $link='', $stretch=0)
    Cell(宽, 高, 内容, 边框, 是否换行, 文字对齐, 文字底色,连接, 变宽)

    多行文本
    MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0)
    MultiCell(宽, 高, 内容, 边框,文字对齐, 文字底色, 是否换行, x坐标, y坐标, 变高, 变宽, 是否支持html, 自动填充, 最大高度)

    html文字

    setHtmlLinksStyle($color=array(0,0,255), $fontstyle='U');
    setHtmlLinksStyle(颜色默认蓝色, U有下划线);
    addHtmlLink($url, $name, $fill=0, $firstline=false, $color='', $style=-1);
    addHtmlLink(超链接地址, 显示文字, 是否有底色, $firstline=false, $color='', $style=-1);

    换行

    Ln($h='', $cell=false);
    Ln(行数, 是否cell);
    例如:
    $pdf->SetProtection(array('print','modify','copy','annot-forms'), '854230');

    图片背景

    Image($file, $x, $y, $w, $h, $type, $link, $align, $resize, $dpi, $palign, $ismask, $imgmask, $border);

    注意:把图片放语句放在前面,并且使用绝对坐标定位,即可做背景。

     转载:https://www.cnblogs.com/520fyl/p/5396374.html

  • 相关阅读:
    生成实用包装码
    区分排序函数
    mysql优化
    高并发、大流量、大存储
    数据库的搬移
    linux查看系统日志及具体服务日志
    springboot拦截器实现
    使用ajax的get请求渲染html
    百度echarts折线图使用示例
    前端特殊符号转码
  • 原文地址:https://www.cnblogs.com/zc290987034/p/10551048.html
Copyright © 2011-2022 走看看