本文实例讲述了php实现往pdf中加数字签名操作。分享给大家供大家参考,具体如下:

//============================================================+

// File name : example_052.php

// Begin : 2009-05-07

// Last Update : 2013-05-14

//

// Description : Example 052 for TCPDF class

// Certification Signature (experimental)

//

// Author: Nicola Asuni

//

// (c) Copyright:

// Nicola Asuni

// Tecnick.com LTD

// www.tecnick.com

// info@tecnick.com

//============================================================+

/**

* Creates an example PDF TEST document using TCPDF

* @package com.tecnick.tcpdf

* @abstract TCPDF - Example: Certification Signature (experimental)

* @author Nicola Asuni

* @since 2009-05-07

*/

// Include the main TCPDF library (search for installation path).

require_once('tcpdf_include.php');

// create new PDF document

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information

$pdf->SetCreator(PDF_CREATOR);

$pdf->SetAuthor('Nicola Asuni');

$pdf->SetTitle('TCPDF Example 052');

$pdf->SetSubject('TCPDF Tutorial');

$pdf->SetKeywords('TCPDF, PDF, example, test, guide');

// set default header data

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

// set header and footer fonts

$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));

$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// set default monospaced font

$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

// set margins

$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);

$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);

$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

// set auto page breaks

$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

// set image scale factor

$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

// set some language-dependent strings (optional)

if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {

require_once(dirname(__FILE__).'/lang/eng.php');

$pdf->setLanguageArray($l);

}

// ---------------------------------------------------------

/*

NOTES:

- To create self-signed signature: openssl req -x509 -nodes -days 365000 -newkey rsa:1024 -keyout tcpdf.crt -out tcpdf.crt

- To export crt to p12: openssl pkcs12 -export -in tcpdf.crt -out tcpdf.p12

- To convert pfx certificate to pem: openssl pkcs12 -in tcpdf.pfx -out tcpdf.crt -nodes

*/

// set certificate file

$certificate = 'file://data/cert/tcpdf.crt';

$certificate = 'file://'.realpath('./data/cert/tcpdf.crt');

// set additional information

$info = array(

'Name' => 'TCPDF',

'Location' => 'Office',

'Reason' => 'Testing TCPDF',

'ContactInfo' => 'http://www.tcpdf.org',

);

// set document signature

$pdf->setSignature($certificate, $certificate, 'tcpdfdemo', '', 2, $info);

// set font

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

// add a page

$pdf->AddPage();

// print a line of text

$text = 'This is a digitally signed document using the default (example) tcpdf.crt certificate.
To validate this signature you have to load the tcpdf.fdf on the Arobat Reader to add the certificate to List of Trusted Identities.
For more information check the source code of this example and the source code documentation for the setSignature() method.www.tcpdf.org';

$pdf->writeHTML($text, true, 0, true, 0);

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

// *** set signature appearance ***

// create content for signature (image and/or text)

$pdf->Image('images/tcpdf_signature.png', 180, 60, 15, 15, 'PNG');

// define active area for signature appearance

$pdf->setSignatureAppearance(180, 60, 15, 15);

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

// *** set an empty signature appearance ***

$pdf->addEmptySignatureAppearance(180, 80, 15, 15);

// ---------------------------------------------------------

//Close and output PDF document

$pdf->Output('example_052.pdf', 'D');

//============================================================+

// END OF FILE

//============================================================+

其中tcpdf_include.php文件(源自tcpdf插件)如下:

//============================================================+

// File name : tcpdf_include.php

// Begin : 2008-05-14

// Last Update : 2014-12-10

//

// Description : Search and include the TCPDF library.

//

// Author: Nicola Asuni

//

// (c) Copyright:

// Nicola Asuni

// Tecnick.com LTD

// www.tecnick.com

// info@tecnick.com

//============================================================+

/**

* Search and include the TCPDF library.

* @package com.tecnick.tcpdf

* @abstract TCPDF - Include the main class.

* @author Nicola Asuni

* @since 2013-05-14

*/

// always load alternative config file for examples

require_once('config/tcpdf_config_alt.php');

// Include the main TCPDF library (search the library on the following directories).

$tcpdf_include_dirs = array(

realpath('../tcpdf.php'),

'/usr/share/php/tcpdf/tcpdf.php',

'/usr/share/tcpdf/tcpdf.php',

'/usr/share/php-tcpdf/tcpdf.php',

'/var/www/tcpdf/tcpdf.php',

'/var/www/html/tcpdf/tcpdf.php',

'/usr/local/apache2/htdocs/tcpdf/tcpdf.php'

);

foreach ($tcpdf_include_dirs as $tcpdf_include_path) {

if (@file_exists($tcpdf_include_path)) {

require_once($tcpdf_include_path);

break;

}

}

//============================================================+

// END OF FILE

//============================================================+

eng.php文件如下:

//============================================================+

// File name : eng.php

// Begin : 2004-03-03

// Last Update : 2010-10-26

//

// Description : Language module for TCPDF

// (contains translated texts)

// English

//

// Author: Nicola Asuni

//

// (c) Copyright:

// Nicola Asuni

// Tecnick.com LTD

// Manor Coach House, Church Hill

// Aldershot, Hants, GU12 4RQ

// UK

// www.tecnick.com

// info@tecnick.com

//============================================================+

/**

* TCPDF language file (contains translated texts).

* @package com.tecnick.tcpdf

* @brief TCPDF language file: English

* @author Nicola Asuni

* @since 2004-03-03

*/

// English

global $l;

$l = Array();

// PAGE META DESCRIPTORS --------------------------------------

$l['a_meta_charset'] = 'UTF-8';

$l['a_meta_dir'] = 'ltr';

$l['a_meta_language'] = 'en';

// TRANSLATIONS --------------------------------------

$l['w_page'] = 'page';

//============================================================+

// END OF FILE

//============================================================+

补充:

tcpdf.crt文件点击此处本站下载。

tcpdf插件点击此处本站下载。

希望本文所述对大家PHP程序设计有所帮助。

php往pdf模板添加数据,php实现往pdf中加数字签名操作示例【附源码下载】相关推荐

  1. php实现电子签名,php实现往pdf中加数字签名操作示例【附源码下载】

    本文实例讲述了php实现往pdf中加数字签名操作.分享给大家供大家参考,具体如下: //======================================================== ...

  2. python二手交易平台代码_PYTHON爬虫实战_垃圾佬闲鱼爬虫转转爬虫数据整合自用二手急速响应捡垃圾平台_3(附源码持续更新)...

    说明 文章首发于HURUWO的博客小站,本平台做同步备份发布. 如有浏览或访问异常图片加载失败或者相关疑问可前往原博客下评论浏览. 原文链接 PYTHON爬虫实战_垃圾佬闲鱼爬虫转转爬虫数据整合自用二 ...

  3. Winforn中实现ZedGraph自定义添加右键菜单项(附源码下载)

    场景 Winform中实现ZedGraph中曲线右键显示为中文: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100115292 ...

  4. echarts asp mysql 源码_如何使用PHP+jQuery+MySQL实现异步加载ECharts地图数据(附源码下载)...

    ECharts地图主要用于地理区域数据的可视化,展示不同区域的数据分布信息.ECharts官网提供了中国地图.世界地图等地图数据下载,通过js引入或异步加载json文件的形式调用地图. 本文将结合实例 ...

  5. 【数据分析与可视化】Pandas可视化与数据透视表的讲解及实战(超详细 附源码)

    需要源码请点赞关注收藏后评论区留言私信~~~ 一.数据透视表 数据透视表(Pivot Table)是数据分析中常见的工具之一,根据一个或多个键值对数据进行聚合,根据列或行的分组键将数据划分到各个区域 ...

  6. php往pdf模板添加数据,用PHP编写/绘制PDF模板文档

    我希望能够用PHP在现有的PDF文档上编写/覆盖文本.我希望做的是有一个pdf文档,它可以作为一个模板,并通过打开模板文档.覆盖相关文本以及将结果作为一个新文档来填补空白.模板文档是一个单独的页面,因 ...

  7. MongoDB数据访问[C#]附源码下载(查询增删改) 转载

    安装完MongoDBhttp://localhost:28017/监测是否成功! vs 2008 C# MongoDB 源代码下载地址:http://download.csdn.net/source/ ...

  8. 如何用Python对股票数据进行LSTM神经网络和XGboost机器学习预测分析(附源码和详细步骤),学会的小伙伴们说不定就成为炒股专家一夜暴富了

    前言 最近调研了一下我做的项目受欢迎程度,大数据分析方向竟然排第一,尤其是这两年受疫情影响,大家都非常担心自家公司裁员或倒闭,都想着有没有其他副业搞搞或者炒炒股.投资点理财产品,未雨绸缪,所以不少小伙 ...

  9. yolov3检测和平精英视频中人物及物体【附源码+数据】

    目录 一.实现效果与数据下载链接 二.相应代码 三.yolo原理讲解 一.实现效果与数据下载链接 视频识别效果,链接如下: https://www.bilibili.com/video/BV1fa4y ...

  10. cesium 3dtiles 加载本地数据_cesium结合geoserver实现地图空间查询(附源码下载)

    前言 cesium 官网的api文档介绍地址cesium官网api,里面详细的介绍 cesium 各个类的介绍,还有就是在线例子:cesium 官网在线例子,这个也是学习 cesium 的好素材. 内 ...

最新文章

  1. Android ndk 安装教程 以及环境变量配置
  2. 13 种在 Linux 系统上检测 CPU 信息的工具
  3. 清华校长送给毕业生的五句话,值得一看!
  4. 【小技巧】字符char与整型int的相互转换
  5. java如何循环调用方法_Java:调用方法的“中断”循环?
  6. 空间皮肤代码_不废话,看我20行代码搞定色块提取与定位…….
  7. GDB调试使用技巧 - 专职C++ - C++博客
  8. 图象和文本的绝对位置(九)
  9. 3、http网络编程——struct linger
  10. linux firefox严重卡顿,Firefox火狐浏览器出现卡顿崩溃等问题的解决方法
  11. 记一次血淋淋的MySQL崩溃修复案例
  12. 自恋的人脑袋有啥不一样?| 自恋型人格特质和前额脑结构
  13. 淘宝打标API,旺旺打标签接口文档
  14. 实现西门子S71200/1500与三菱FX系列PLC通讯
  15. 一顿操作猛如虎,细说MySQL索引的区别
  16. UEFI模式改为BIOS模式
  17. CodeForces 1098D. Eels
  18. MATLAB 找到n阶方阵中对角线上的连续素数个数 不使用循环
  19. 【AD封装】915MHz天线,GPS天线,GSM天线,433MHz天线,13.56Hz天线,LTE天线
  20. 系统修复软件测试工资,技术员们有福了,关于怎么用MHDD修复硬盘坏道,现在免费给大家了!!!...

热门文章

  1. 使用python解决算法和数据结构--使用栈实现进制转换
  2. hadoop ha环境下的datanode启动报错java.lang.NumberFormatException: For input string: 10m
  3. 剑指offer:字符串的排列
  4. 第9月第6天 push pop动画 生成器模式(BUILDER)
  5. 关于fragment保存变量的问题
  6. [Linux_Ubuntu13] 声音很小前台无法调节的处理方法
  7. spring源码-第四个后置处理器
  8. 网络安全与管理精讲视频笔记4-数字信封、数字签名、完整性验证、数据加解密及身份认证流程...
  9. 业务重点-实现一个简单的手机号码验证
  10. React.js和Vue.js有感—前端开发组件化思想的局部要点理解