Heim  >  Artikel  >  php教程  >  php生成PDF格式文件并且加密,

php生成PDF格式文件并且加密,

WBOY
WBOYOriginal
2016-06-13 09:00:091680Durchsuche

php生成PDF格式文件并且加密,

项目需求:php生成pdf文件,并且把该文件加密或设置访问密码

开源的TCPDF是基于PHP的一套类库,它能够很好的生成PDF格式的文档。并且支持文件加密,在目前的开源PHP框架、系统、应用中也使用得很广。这里是设置PDF文档的相关属性的方法原型,其中就可以设置密码

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

通过SetProtection()方法设置后,生成的PDF文档就是加密过的,在用户打开PDF文档的时候就会要求输入访问密码

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn