Jump to content
  • Hello visitors, welcome to the Hacker World Forum!

    Red Team 1949  (formerly CHT Attack and Defense Team) In this rapidly changing Internet era, we maintain our original intention and create the best community to jointly exchange network technologies. You can obtain hacker attack and defense skills and knowledge in the forum, or you can join our Telegram communication group to discuss and communicate in real time. All kinds of advertisements are prohibited in the forum. Please register as a registered user to check our usage and privacy policy. Thank you for your cooperation.

    TheHackerWorld Official

Recommended Posts

1. composer 安装 PDF组件

  composer require setasign/fpdi

  composer require setasign/fpdf

  两个组件都需要安装,有依赖关系

 

2. 使用

  

<?php

      try {
            $fpdi = new Fpdi();
       // 设置待处理PDF文件,并且方法返回PDF总计页数
            $pagecount1 = $fpdi->setSourceFile("C:\Users\83553\Desktop\pdf\员工保密协议(2).pdf");
            for ($i=1;$i<=$pagecount1;$i++) {
          // 增加新的空白PDF页面 $fpdi->AddPage();
          // 导入页面 $tplId = $fpdi->importPage($i);
          // 填充页面 $fpdi->useTemplate($tplId); }
       // 以下同理,因为多个PDF文件,所以多次,需要合并的PDF文件过程,可以使用循环,次示例仅供参考(示例可跑通) $pagecount2 = $fpdi->setSourceFile("C:\Users\83553\Desktop\pdf\怎样写好工作总结(1).pdf"); for ($j=1;$j<=$pagecount2;$j++) { $fpdi->AddPage(); $tplIdkk = $fpdi->importPage($j); $fpdi->useTemplate($tplIdkk); } $pagecount3 = $fpdi->setSourceFile("C:\Users\83553\Desktop\pdf\租房协议书.pdf"); for ($k=1;$k<=$pagecount3;$k++) { $fpdi->AddPage(); $tplIdoo = $fpdi->importPage($k); $fpdi->useTemplate($tplIdoo); }         // D 代表下载 I 代表预览 F代表保存 S代表返回String $fpdi->Output("D", "test.pdf"); } catch (\Exception $exception) { echo $exception->getMessage(); }

 

Link to post
Link to comment
Share on other sites

 Share

discussion group

discussion group

    You don't have permission to chat.
    • Recently Browsing   0 members

      • No registered users viewing this page.
    ×
    ×
    • Create New...