當前位置:首頁 » 編程語言 » tcpdfphp

tcpdfphp

發布時間: 2023-09-05 08:05:44

php生成PDF格式文件並且加密

本文給大家介紹的是如何使用php生成pdf文件,並且把該文件加密或設置訪問密碼的方法,有需要的小夥伴可以參考下。
項目需求:php生成pdf文件,並且把該文件加密或設置訪問密碼
開源的TCPDF是基於PHP的一套類庫,它能夠很好的生成PDF格式的文檔。並且支持文件加密,在目前的開源PHP框架、系統、應用中也使用得很廣。這里是設置PDF文檔的相關屬性的方法原型,其中就可以設置密碼
?
1
2
3
4
5
6
7
8
TCPDF::SetProtection
(
$permissions
=
array('print',
'modify',
'',
'annot-forms',
'fill-forms',
'extract',
'assemble',
'print-high'),
$user_pass
=
'',
$owner_pass
=
null,
$mode
=
0,
$pubkeys
=
null
)
通過SetProtection()方法設置後,生成的PDF文檔就是加密過的,在用戶打開PDF文檔的時候就會要求輸入訪問密碼

❷ 如何使用PHP創建和修改PDF文檔

示例一:使用PHP生成一個簡單的PDF文檔

以下為引用的內容:
require_once('../config/lang/eng.php');
require_once('../tcpdf.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 002');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');

// remove default header/footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

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

//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
$pdf->setLanguageArray($l);

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

// set font
$pdf->SetFont('times', 'BI', 20);

熱點內容
密碼編譯找規律 發布:2025-07-10 09:18:10 瀏覽:510
電影視頻緩存後 發布:2025-07-10 09:16:48 瀏覽:891
伺服器搭建需要哪些東西 發布:2025-07-10 09:15:23 瀏覽:800
無限密碼怎麼改 發布:2025-07-10 09:14:32 瀏覽:103
coc按鍵精靈腳本 發布:2025-07-10 09:12:40 瀏覽:310
excel表格ftp函數 發布:2025-07-10 09:05:50 瀏覽:276
u2game的解壓密碼 發布:2025-07-10 09:05:14 瀏覽:597
c語言編譯器ide蘋果下載 發布:2025-07-10 09:05:13 瀏覽:293
andftp埠 發布:2025-07-10 08:57:04 瀏覽:606
戰地一有什麼不用加速器的伺服器 發布:2025-07-10 08:51:33 瀏覽:405