pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <i id='f6QTV'><tr id='f6QTV'><dt id='f6QTV'><q id='f6QTV'><span id='f6QTV'><b id='f6QTV'><form id='f6QTV'><ins id='f6QTV'></ins><ul id='f6QTV'></ul><sub id='f6QTV'></sub></form><legend id='f6QTV'></legend><bdo id='f6QTV'><pre id='f6QTV'><center id='f6QTV'></center></pre></bdo></b><th id='f6QTV'></th></span></q></dt></tr></i><div class="6qq2uug" id='f6QTV'><tfoot id='f6QTV'></tfoot><dl id='f6QTV'><fieldset id='f6QTV'></fieldset></dl></div>

      <tfoot id='f6QTV'></tfoot>
        <bdo id='f6QTV'></bdo><ul id='f6QTV'></ul>

      1. <legend id='f6QTV'><style id='f6QTV'><dir id='f6QTV'><q id='f6QTV'></q></dir></style></legend>

        <small id='f6QTV'></small><noframes id='f6QTV'>

      2. PHP - 如何使用 mPDF 合并 PDF

        PHP - How to use mPDF to merge PDFs(PHP - 如何使用 mPDF 合并 PDF)
          <bdo id='IM3Kc'></bdo><ul id='IM3Kc'></ul>

          <i id='IM3Kc'><tr id='IM3Kc'><dt id='IM3Kc'><q id='IM3Kc'><span id='IM3Kc'><b id='IM3Kc'><form id='IM3Kc'><ins id='IM3Kc'></ins><ul id='IM3Kc'></ul><sub id='IM3Kc'></sub></form><legend id='IM3Kc'></legend><bdo id='IM3Kc'><pre id='IM3Kc'><center id='IM3Kc'></center></pre></bdo></b><th id='IM3Kc'></th></span></q></dt></tr></i><div class="gsowsm0" id='IM3Kc'><tfoot id='IM3Kc'></tfoot><dl id='IM3Kc'><fieldset id='IM3Kc'></fieldset></dl></div>
          <legend id='IM3Kc'><style id='IM3Kc'><dir id='IM3Kc'><q id='IM3Kc'></q></dir></style></legend>
          <tfoot id='IM3Kc'></tfoot>

              • <small id='IM3Kc'></small><noframes id='IM3Kc'>

                  <tbody id='IM3Kc'></tbody>

                  本文介紹了PHP - 如何使用 mPDF 合并 PDF的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我首先會說我可以用 mPDF 很好地生成 PDF,但對于我的生活,我無法讓它將現有的 PDF 與它剛剛生成的 PDF 合并.

                  I will start out by saying that I can generate PDFs just fine with mPDF, but for the life of me, I can't get it to merge an existing PDF with the PDF it just generated.

                  我需要弄清楚的是如何將現有的 PDF 附加/添加到新生成的 PDF.我已經嘗試使用 mPDF 方法來導入頁面,但我得到的只是一個錯誤,如:

                  What I need to figure out is how to append/add the existing PDF to the newly generated PDF. I've tried using the mPDF methods for importing pages, but all I can get is an error like:

                  mPDF error: Cannot open '/downloads/test.pdf'.
                  

                  上述消息含糊不清,不清楚為什么它無法打開文件...這是我用來嘗試合并 PDF 的代碼:

                  The above message is ambiguous and unclear as to WHY it can't open the file... Here's the code I'm using to try and merge PDFs:

                   include_once("./pdf/mpdf/mpdf.php");
                  
                   $output_file = $_GET['output_file'];
                   $url = $_GET['input_file'];
                   $technical_drawing = $_GET['tech_drawing'];
                  
                   $html = file_get_contents($url);
                  
                   $mpdf = new mPDF('utf-8','Letter','','',0,0,0,0,0,0,'P');
                   $mpdf->SetImportUse(); 
                  
                   $pagecount = $mpdf->SetSourceFile($technical_drawing);
                   $tplIdx = $mpdf->ImportPage($pagecount);
                   $mpdf->UseTemplate($tplIdx);
                  
                   $mpdf->WriteHTML($html);
                   $mpdf->Output($output_file, 'D');
                  
                   exit;
                  

                  $output_file 將是顯示給用戶的文件名.$url 是我們在 PDF 生成期間寫入文件的 HTML.$technical_drawing 是我們想要與生成的 PDF 附加/合并的 PDF 的相對路徑.

                  $output_file will be the filename shown to the user. $url is the HTML we're writing into the file during PDF generation. $technical_drawing is a relative path to a PDF that we want to append/merge with the generated PDF.

                  我知道我可以使用諸如 ghostscript 之類的東西,但我在客戶端的服務器上沒有這種類型的訪問權限.

                  I understand I could use something like ghostscript, but I don't have that type of access on the client's server.

                  讓我知道是否有人使用 mPDF 找到了解決方案,或者如果我是 S.O.L.并且需要找到另一個庫來進行 PDF 合并.我真的在尋找解決方案或建議,而不僅僅是指向另一個庫的鏈接.我已經用盡了我在 Google 或 mPDF 文檔中可以找到的描述我遇到的錯誤的內容.

                  Let me know if anyone has found a solution to this using mPDF or if I'm S.O.L. and need to find another library to do PDF merging. I am really looking for solutions or suggestions, but not just links to another library. I've exhausted what I can find in Google or in mPDF's documentation that describes the error I'm having.

                  將 mPDF 錯誤從 http://example.com/pdf/example.pdf 更改為 '/downloads/test.pdf'.

                  changed mPDF error from http://example.com/pdf/example.pdf to '/downloads/test.pdf'.

                  EDIT_2:已修復代碼以采用相對路徑.

                  EDIT_2: Code has been fixed to take relative path.

                  這是最終的工作代碼.如果有人知道如何指定將 HTML 寫入 PDF 文檔的順序,將頁面作為最后一頁導入(自定義頁面大小不同于 HTML 的自定義頁面大小),則獎勵.

                  Here's final working code. Bonus if anyone knows how to specify the order of writing HTML to PDF document, importing page as last page (with custom page size different from that of the HTML).

                      include_once("./pdf/mpdf/mpdf.php");
                  
                      $output_file = 'test-' . $_GET['output_file'];
                      $url = $_GET['input_file'];
                      $technical_drawing = $_GET['tech_drawing'];
                  
                      $html = file_get_contents($url);
                  
                  
                      if(!file_exists($technical_drawing)) {
                        $mpdf = new mPDF('utf-8','Letter','','',0,0,0,0,0,0,'L');
                      } else {
                        $mpdf = new mPDF('utf-8','A3-L','','',0,0,0,0,0,0,'L');
                  
                        $mpdf->SetImportUse(); 
                  
                        $pagecount = $mpdf->SetSourceFile($technical_drawing);
                        $import_page = $mpdf->ImportPage();
                  
                        $mpdf->UseTemplate($import_page);
                  
                        // Add Last page
                        $mpdf->AddPageByArray(array(
                          'orientation' => 'P',
                          'ohvalue' => 1,
                          'ehvalue' => -1,
                          'ofvalue' => -1,
                          'efvalue' => -1,
                          'newformat' => 'Letter'
                        ));
                      }
                  
                      $mpdf->WriteHTML($html);
                      $mpdf->Output($output_file, 'D');
                  
                      exit;
                  

                  推薦答案

                  我像這樣合并 pdf - {所有文件中的所有頁面}:

                  I Merge pdfs like this - {all pages in all files}:

                  $this = 擴展 mPDF 類的類...

                  $this = Class that extends mPDF class...

                  function mergePDFFiles(Array $filenames, $outFile)
                  {
                      if ($filenames) {
                  
                          $filesTotal = sizeof($filenames);
                          $fileNumber = 1;
                  
                          $this->SetImportUse(); // this line comment out if method doesnt exist
                  
                          if (!file_exists($outFile)) {
                              $handle = fopen($outFile, 'w');
                              fclose($handle);
                          }
                  
                          foreach ($filenames as $fileName) {
                              if (file_exists($fileName)) {
                                  $pagesInFile = $this->SetSourceFile($fileName);
                                  for ($i = 1; $i <= $pagesInFile; $i++) {
                                      $tplId = $this->ImportPage($i); // in mPdf v8 should be 'importPage($i)'
                                      $this->UseTemplate($tplId);
                                      if (($fileNumber < $filesTotal) || ($i != $pagesInFile)) {
                                          $this->WriteHTML('<pagebreak />');
                                      }
                                  }
                              }
                              $fileNumber++;
                          }
                  
                          $this->Output($outFile);
                  
                      }
                  
                  }
                  

                  這篇關于PHP - 如何使用 mPDF 合并 PDF的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
                  1. <small id='B0qRx'></small><noframes id='B0qRx'>

                      <legend id='B0qRx'><style id='B0qRx'><dir id='B0qRx'><q id='B0qRx'></q></dir></style></legend>
                      <i id='B0qRx'><tr id='B0qRx'><dt id='B0qRx'><q id='B0qRx'><span id='B0qRx'><b id='B0qRx'><form id='B0qRx'><ins id='B0qRx'></ins><ul id='B0qRx'></ul><sub id='B0qRx'></sub></form><legend id='B0qRx'></legend><bdo id='B0qRx'><pre id='B0qRx'><center id='B0qRx'></center></pre></bdo></b><th id='B0qRx'></th></span></q></dt></tr></i><div class="2222k2s" id='B0qRx'><tfoot id='B0qRx'></tfoot><dl id='B0qRx'><fieldset id='B0qRx'></fieldset></dl></div>
                      <tfoot id='B0qRx'></tfoot>

                            <tbody id='B0qRx'></tbody>
                            <bdo id='B0qRx'></bdo><ul id='B0qRx'></ul>
                            主站蜘蛛池模板: 安平县鑫川金属丝网制品有限公司,声屏障,高速声屏障,百叶孔声屏障,大弧形声屏障,凹凸穿孔声屏障,铁路声屏障,顶部弧形声屏障,玻璃钢吸音板 | 哔咔漫画网页版在线_下载入口访问指引 | 骨密度仪-骨密度测定仪-超声骨密度仪-骨龄测定仪-天津开发区圣鸿医疗器械有限公司 | 空压机网_《压缩机》杂志| 铝镁锰板_铝镁锰合金板_铝镁锰板厂家_铝镁锰金属屋面板_安徽建科 | 干法制粒机_智能干法制粒机_张家港市开创机械制造有限公司 | 细石混凝土泵_厂家_价格-烟台九达机械有限公司 | SOUNDWELL 编码器|电位器|旋转编码器|可调电位器|编码开关厂家-广东升威电子制品有限公司 | 无水硫酸铝,硫酸铝厂家-淄博双赢新材料科技有限公司 | 广州冷却塔维修厂家_冷却塔修理_凉水塔风机电机填料抢修-广东康明节能空调有限公司 | 深圳VI设计-画册设计-LOGO设计-包装设计-品牌策划公司-[智睿画册设计公司] | 企典软件一站式企业管理平台,可私有、本地化部署!在线CRM客户关系管理系统|移动办公OA管理系统|HR人事管理系统|人力 | 伊卡洛斯软装首页-电动窗帘,别墅窗帘,定制窗帘,江浙沪1000+别墅窗帘案例 | 无线联网门锁|校园联网门锁|学校智能门锁|公租房智能门锁|保障房管理系统-KEENZY中科易安 | 自清洗过滤器,浅层砂过滤器,叠片过滤器厂家-新乡市宇清净化 | 棕刚玉-白刚玉厂家价格_巩义市东翔净水材料厂| 丹佛斯变频器-丹佛斯压力开关-变送器-广州市风华机电设备有限公司 | 乙炔气体报警装置|固定式氯化氢检测仪|河南驰诚电气百科 | 河南道路标志牌_交通路标牌_交通标志牌厂家-郑州路畅交通 | 传动滚筒,改向滚筒-淄博建凯机械科技有限公司 | 塑胶地板-商用PVC地板-pvc地板革-安耐宝pvc塑胶地板厂家 | 2025第九届世界无人机大会 | 大鼠骨髓内皮祖细胞-小鼠神经元-无锡欣润生物科技有限公司 | 全自动五线打端沾锡机,全自动裁线剥皮双头沾锡机,全自动尼龙扎带机-东莞市海文能机械设备有限公司 | 智能门锁电机_智能门锁离合器_智能门锁电机厂家-温州劲力智能科技有限公司 | 对辊式破碎机-对辊制砂机-双辊-双齿辊破碎机-巩义市裕顺机械制造有限公司 | 盐城网络公司_盐城网站优化_盐城网站建设_盐城市启晨网络科技有限公司 | 陕西华春网络科技股份有限公司 | 高防护蠕动泵-多通道灌装系统-高防护蠕动泵-www.bjhuiyufluid.com慧宇伟业(北京)流体设备有限公司 | 太平洋亲子网_健康育儿 品质生活| 巩义市科瑞仪器有限公司| 刮板输送机,粉尘加湿搅拌机,螺旋输送机,布袋除尘器 | 周口市风机厂,周鼓风机,河南省周口市风机厂 | 蓝莓施肥机,智能施肥机,自动施肥机,水肥一体化项目,水肥一体机厂家,小型施肥机,圣大节水,滴灌施工方案,山东圣大节水科技有限公司官网17864474793 | 土壤肥料养分速测仪_测土配方施肥仪_土壤养分检测仪-杭州鸣辉科技有限公司 | 木材烘干机,木炭烘干机,纸管/佛香烘干设备-河南蓝天机械制造有限公司 | BOE画框屏-触摸一体机-触控查询一体机-触摸屏一体机价格-厂家直销-触发电子 | 酒糟烘干机-豆渣烘干机-薯渣烘干机-糟渣烘干设备厂家-焦作市真节能环保设备科技有限公司 | 河南砖机首页-全自动液压免烧砖机,小型砌块水泥砖机厂家[十年老厂] | 全自动五线打端沾锡机,全自动裁线剥皮双头沾锡机,全自动尼龙扎带机-东莞市海文能机械设备有限公司 | 抓斗式清污机|螺杆式|卷扬式启闭机|底轴驱动钢坝|污水处理闸门-方源水利机械 |