PHP使用FPDF pdf添加水印中文亂碼問題 pdf合並版本問題


---恢復內容開始---

require_once('../fpdf/fpdf.php');
require_once('../fpdi/fpdi.php');

使用此插件 pdf 合並 並添加水印 期間遇到添加水印 中文亂碼問題 

解決辦法:

require ('chinese.php') 基本百度都是這個  都可以解決此問題

但我這邊還用到fpdi.php的方法 所以我是將代碼整合到fpdi.php中

重點:

    $pdf = new FPDI();  
    //設置字體要在實例化之后就設置 否則會報錯
    $pdf->AddGBFont('simhei','黑體');
    $pdf->SetFont('simhei', '', 13);

參考網頁:

https://blog.csdn.net/qq_29238009/article/details/73946978

https://github.com/DCgithub21/cd_FPDF

http://justcoding.iteye.com/blog/2163069

 

fpdi合並時候遇到pdf 版本過高 導致合並不成功  解決辦法:

用php 調用 Ghostscript 組件 https://github.com/ArtifexSoftware/ghostpdl-downloads/releases  Ghostscript 下載地址 

https://stackoverflow.com/questions/4794435/merge-pdf-files-with-php#  參考示例

//調用ghostscript合並pdf方法
function hbpdf_gs($files,$out_file_new3){
    $cmd = "\"C:\\Program Files\\gs\\gs9.25\\bin\\gswin64c.exe\" -q -dNOPAUSE -dBATCH -dCompatibilityLevel=1.4 -sDEVICE=pdfwrite -sOutputFile=".$out_file_new3." ".implode(" ", $files);
    try{
        $result = exec($cmd);
    }catch (Exception $e) {  
        print $e->getMessage();  
        exit();
    }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM