1、TCPDF 背景图片透明度 

参考:https://bbs.csdn.net/topics/392364981

效果:

2、画一条线:

2.1方法解说 

/*画一条线:

x1:线条起点x坐标

y1:线条起点y坐标

x2:线条终点x坐标

y2:线条终点y坐标

style:SetLineStyle的效果一样

*/

//       $pdf->Line($x1, $y1, $x2, $y2, $style=array());

 2.2方法使用:

  1. /*线的颜色*/
  2. $this->SetLineStyle(array('width' => 0, 'cap' => 'butt', 'join' => 'miter', 'dash' => '0', 'color' => array(220, 20,60)));
  3. /*画一条线*/
  4. $this->Line(1, 100, 100, 1, $style=array());
  5.  
  6. /*加入一条下划线 下划线颜色默认为黑色,用此方法【SetLineStyle()】可以自定义线的颜色 */
  7. $this->Cell(180, 0, '', 1, 0, 'C', 0, '', 0, true);

2.3效果:

3.自定义页眉页脚:

  1. /*
  2. *
  3. * */
  4. function zidingyi_yemei(){
  5. //============================================================+
  6. // File name : example_003.php
  7. // Begin : 2008-03-04
  8. // Last Update : 2013-05-14
  9. //
  10. // Description : Example 003 for TCPDF class
  11. // Custom Header and Footer
  12. //
  13. // Author: Nicola Asuni
  14. //
  15. // (c) Copyright:
  16. // Nicola Asuni
  17. // Tecnick.com LTD
  18. // www.tecnick.com
  19. // info@tecnick.com
  20. //============================================================+
  21.  
  22. /**
  23. * Creates an example PDF TEST document using TCPDF
  24. * @package com.tecnick.tcpdf
  25. * @abstract TCPDF - Example: Custom Header and Footer
  26. * @author Nicola Asuni
  27. * @since 2008-03-04
  28. */
  29.  
  30. // Include the main TCPDF library (search for installation path).
  31. require_once('ThinkPHP/Library/Vendor/tcpdf/tcpdf.php');
  32.  
  33. // Extend the TCPDF class to create custom Header and Footer
  34. class MYPDF extends TCPDF {
  35.  
  36. //Page header
  37. /*public function Header() {
  38. // Logo
  39. $image_file = K_PATH_IMAGES.'bl_logo.png';
  40. $this->Image($image_file, 10, 10, 15, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);
  41. // Set font
  42. $this->SetFont('helvetica', 'B', 20);
  43. // Title
  44. $this->Cell(0, 15, '<< TCPDF Example 003 >>', 0, false, 'C', 0, '', 0, false, 'M', 'M');
  45. }
  46.  
  47. // Page footer
  48. public function Footer() {
  49. // Position at 15 mm from bottom
  50. $this->SetY(-15);
  51. // Set font
  52. $this->SetFont('helvetica', 'I', 8);
  53. // Page number
  54. $this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
  55. }*/
  56. //Page header 自定义页眉
  57. public function Header() {
  58. $this->SetFont('stsongstdlight', '', 10);
  59. $this->SetHeaderData('', '', ''.' 001', '', array(0,64,255), array(0,64,128));
  60. // Title
  61. $this->SetY(1);
  62. $image_file = K_PATH_IMAGES.'bl_logo.png';
  63. $this->SetY(1);
  64. $this->Image($image_file, 15, 3.2, 5, '', 'PNG', '', 'T', false, 300, '', false, false, 0, false, false, false);
  65. $this->SetY(3.7);
  66. $left_text = '<p style="text-indent: 20px; color: #00489A; font-weight: bold;">山东保蓝环保工程有限公司</p>';
  67. //$this->Write(0, $left_text, '', 0, 'L', true, 0, false, false, 0);
  68. $this->writeHTML($left_text, 1, false, true, false, 'L');
  69. $this->SetY(3.7);
  70. $right_text = '<p style="color: #00489A; font-weight: bold;">技术方案</p>';
  71. $this->writeHTML($right_text, 1, false, true, false, 'R');
  72. /*$this->Cell(0, 10, ' 山东保蓝环保工程有限公司', 0, 0, 'L');
  73. $this->Cell(0, 10, '技术方案', 0, 0, 'R');*/
  74. //$this->SetX(1);
  75. $this->SetY(9);
  76. /*页眉下划线颜色*/
  77. $this->SetLineStyle(array('width' => 0, 'cap' => 'butt', 'join' => 'miter', 'dash' => '0', 'color' => array(128,128,128)));
  78. /*靠左面的距离,左上角的距离 ,长度,右上角的距离*/
  79. $this->Line(14, 8.6, 196, 8.6, $style=array());
  80.  
  81. $this->SetY(19);
  82. /*页眉下划线*/
  83. $this->Cell(180, 0, '', 1, 0, 'C', 0, '', 0, true);
  84. }
  85.  
  86. // Page footer 自定义页脚
  87. public function Footer() {
  88. // Position at 15 mm from bottom
  89. $this->SetY(-15);
  90. // Set font
  91. $this->SetFont('helvetica', 'I', 8);
  92. // Page number
  93. $this->Cell(0, 10, ' '.$this->getAliasNumPage().' / '.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
  94. }
  95. /*function Header() //设定页眉
  96. {
  97. $this->SetFont('stsongstdlight','',10);
  98. $this->Write(10,'IPv6协议一致性测试报告','',false,'C');
  99.  
  100. $this->Ln(20);
  101. }
  102.  
  103. function Footer() //设定页脚
  104. {
  105. $this->SetY(-15);
  106. $this->SetFont('stsongstdlight','',10);
  107. $this->Cell(0,10,'第'.$this->PageNo().'页',0,0,'R');
  108. }*/
  109. }
  110.  
  111. // create new PDF document
  112. $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  113.  
  114. // set document information
  115. $pdf->SetCreator(PDF_CREATOR);
  116. $pdf->SetAuthor('Nicola Asuni');
  117. $pdf->SetTitle('TCPDF Example 003');
  118. $pdf->SetSubject('TCPDF Tutorial');
  119. $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  120.  
  121. // set default header data
  122. $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
  123.  
  124. // set header and footer fonts
  125. $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
  126. $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
  127.  
  128. // set default monospaced font
  129. $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  130.  
  131. // set margins
  132. $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
  133. $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
  134. $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
  135.  
  136. // set auto page breaks
  137. $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  138.  
  139. // set image scale factor
  140. $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  141.  
  142. // set some language-dependent strings (optional)
  143. if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
  144. require_once(dirname(__FILE__).'/lang/eng.php');
  145. $pdf->setLanguageArray($l);
  146. }
  147.  
  148. // ---------------------------------------------------------
  149.  
  150. // set font
  151. $pdf->SetFont('times', 'BI', 12);
  152.  
  153. // add a page
  154. $pdf->AddPage();
  155.  
  156. // set some text to print
  157. $txt = <<<EOD
  158. TCPDF Example 003
  159.  
  160. Custom page header and footer are defined by extending the TCPDF class and overriding the Header() and Footer() methods.
  161. EOD;
  162.  
  163. // print a block of text using Write()
  164. $pdf->Write(0, $txt, '', 0, 'C', true, 0, false, false, 0);
  165.  
  166. // ---------------------------------------------------------
  167.  
  168. //Close and output PDF document
  169. $pdf->Output('example_003.pdf', 'I');
  170.  
  171. //============================================================+
  172. // END OF FILE
  173. //============================================================+
  174.  
  175. }

 效果:

TCPDF 背景图片透明度的更多相关文章

  1. TextView字体和背景图片 设置透明度

    背景图片透明度设置  viewHolder.relative_layout.getBackground().setAlpha(225);     0  ---  225 ((TextView)tv). ...

  2. android设置背景图片透明

    设置Activiyt为透明可以在Activity中引用系统透明主题android:theme="@android:style/Theme.Translucent" 设置背景图片透明 ...

  3. Hexo瞎折腾系列(2) - 添加背景图片轮播

    动态背景图片插件jquery-backstretch jquery-backstretch是一款简单的jQuery插件,可以用来设置动态的背景图片,以下是官方网站的介绍. A simple jQuer ...

  4. app引导页(背景图片切换加各个页面动画效果)

    前言:不知不觉中又加班到了10点半,整个启动页面做了一天多的时间,一共有三个页面,每个页面都有动画效果,动画效果调试起来麻烦,既要跟ios统一,又要匹配各种不同的手机,然后产品经理还有可能在中途改需求 ...

  5. 解决android:background背景图片被拉伸问题

    ImageView中XML属性src和background的区别: background会根据ImageView组件给定的长宽进行拉伸,而src就存放的是原图的大小,不会进行拉伸.src是图片内容(前 ...

  6. Duilib技巧:背景图片平铺

    贴图的描述 方式有两种    // 1.aaa.jpg    // 2.file='aaa.jpg' res='' restype='0' dest='0,0,0,0' source='0,0,0,0 ...

  7. WPF 渐隐渐现切换背景图片

    最近学习WPF,尝试着自己做一些小玩意,也遇到了一些问题,于是整理记录以便日后查阅. 我们都知道WPF可以实现一些很炫的效果,然而有时候为达到这个目的却并不是一件很容易的事情.比如:在软件中我希望能够 ...

  8. html之改变图片透明度而不改变文字的透明度--两种方法实现

    图片与图片上的文字设置不同的透明度的两种方法: 第一种方法:背景图+定位+background: url(timg.jpg)no-repeat; <!DOCTYPE html> <h ...

  9. 设置VS2017背景图片

    设置方法很简单:安装扩展ClaudiaIDE 1.在这里下载扩展,https://visualstudiogallery.msdn.microsoft.com/9ba50f8d-f30c-4e33-a ...

随机推荐

  1. NB学校的NB课程的NB教材——CSAPP

    CMU是全美以至全球公认的CS最猛的大学之一,没办法,作为CS的发源地,再加上三位神一样的人先后在此任教:Alan Perlis(CS它祖宗+第一届Turing奖获得者).Allen Newell(A ...

  2. The walking dead

    邪恶令好人团结 Facing evil brings good people together 只是没有人觉得自己是邪恶的一边 No one ever thinks that they’re the ...

  3. python的pandas库学习笔记

    导入: import pandas as pd from pandas import Series,DataFrame 1.两个主要数据结构:Series和DataFrame (1)Series是一种 ...

  4. 饮冰三年-人工智能-Python-28 企业官网(组合搜索)

    1 2:组合搜索 2.1 创建model类 from django.db import models class Direction(models.Model): """ ...

  5. JDBC 连接

    转载至:https://www.liyongzhen.com/ 在这一小节,我们将学习DriverManager对象和connection对象. DriverManager对象用于从驱动里获取一个co ...

  6. hdfs 架构

    http://matt33.com/2018/07/15/hdfs-architecture-learn/

  7. C语言作业06--结构体&文件

    1.本章学习总结 1.1 思维导图 1.2学习体会 在本周的学习中,我们学习了关于结构体和文件的内容.定义结构体可以使代码整个练习更加紧密,非常实用,当我们需要在对一个个体的不同属性调用时可以更加系统 ...

  8. 蓝桥杯 卡片换位(bfs)

    卡片换位 你玩过华容道的游戏吗?这是个类似的,但更简单的游戏.看下面 3 x 2 的格子 在其中放5张牌,其中A代表关羽,B代表张飞,* 代表士兵.还有一个格子是空着的. 你可以把一张牌移动到相邻的空 ...

  9. maya cmds pymel selectType() 选择类型切换

    maya cmds pymel selectType() 选择类型切换 import maya.cmds as cmds cmds.selectType( polymeshFace = True ) ...

  10. input autocomplete属性设计输入框自动联想(php实现)

    因为客户临时要求加一个输入框自动联想,就开始了解这块.结合网上总结最难的一点就是找好对应的js版本以及相应的jQuery-ui: 以下是我用的版本,以及连接地址: jQuery的js文件: <s ...