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();
    }
}
原文地址:https://www.cnblogs.com/lh460795/p/9634982.html