tcpdf 打印PDF字体乱码,通过视图解决方法

本文介绍了在使用TCPDF库进行PDF打印时遇到字体乱码的问题,重点讲解了如何通过调整PHP控制器和视图文件(chargeCreate.blade.php, chargePdf.blade.php)来解决这个问题,确保PDF正确显示字体。" 111548062,10293610,Python正则表达式实战:高效提取文本信息,"['Python', '正则表达式', '文本分析', '字符串操作', '数据提取']
摘要由CSDN通过智能技术生成

路由
routes.php

 $router->get('charge', SamProofingController::class.'@charge');
        $router->get('totalCharge', SamProofingController::class.'@totalCharge')->name('totalCharge');
        $router->get('printCharge',  SamProofingController::class.'@printCharge');

控制器代码

    public function charge(Content $content)
    {
   
        $back_url = $_SERVER["QUERY_STRING"];
        $dep = DingBranch::where('name','like','%业务%')->get()->toArray();
        return $content
            ->header($this->charge_title)
            ->description($this->description['total'])
            ->breadcrumb(
                ['text' => $this->charge_title, 'url' => '/samproofing/charge'.$back_url],
                ['text' => $this->description['total']]
            )
            ->row(view('temp.proofing.chargeCreate',['back_url'=>$back_url,'dep'=>$dep]));
    }
    
     // 查询统计
    public function totalCharge(Request $request)
    {
   
        $type_id = $request->type_id;
        $depid =  $request->depid;
        $start_date =  $request->start_date;
        $end_date =  $request->end_date;
        $title = '板房';
        if (!$start_date){
   
            //当前月1日 00:00:00
            $start_date= date('Y-m-d 00:00:00', strtotime(date('Y-m', time()) . '-01 00:00:00'));
        }
        if (!$end_date){
   
            $end_date = getDateH(0);
        }

        try{
   
            $data = ProofingNotice::with(['notice_size','exploit'=>function($qs) use($depid){
   
                if (isset($depid)){
   
                    $qs->with(['client','brand','devedep','deveaids','client_branch'])->where('deve_dep',$depid);
                }
                else{
   
                    $qs->with(['client','brand','devedep','deveaids','client_branch']);
                }
            },  'colors'=>function($qc){
   
                $qc->with(['place']);
            }])
               // ->where($where)
                ->whereBetween('submit_date', [$start_date, $end_date])
//                ->select('exploit_id','color_id','properties_id','submit_date')
//                ->selectRaw("count(properties_id) as count_qty")
//                ->groupBy('exploit_id','color_id','properties_id','submit_date')
                ->get()->toArray();

            //dd($data);
            $res = [];
            $pattern = 0;
            $sample = 0;
            if(count($data)>0 && isset($data[0]['exploit'])){
   
                foreach ($data as $k=>$v) {
   
                    $res[$k]['client_brach'] = $v['exploit']['client']['name'].'-'.$v['exploit']['client_branch']['title'];
                    $res[$k]['brand_name'] = $v['exploit']['brand']['title'];
                    $res[$k]['exploit_no'] = $v['exploit']['exploit_no'];
                    $res[$k]['deve_dep'] = $v['exploit']['devedep']['name'];
                    $res[$k]['product_name'] = $v['colors']['place']['title'];
                    $res[$k]['properties'] = sample_properties()[$v['properties_id']];
                    $res[$k]['deve_aid'] = $v['exploit']['deveaids']['name'];
                   // $res[$k]['qty'] = $v['count_qty'];
                    $res[$k]['submit_date'] = date('Y-m-d',strtotime($v['submit_date'])) ;
                    $res[$k]['price'] = '';
                    $res[$k]['total'] = '';
                    if (count($v['notice_size'])>0){
   
                        $pattern = array_sum(array_column($v['notice_size'], 'pattern'));
                        $sample =  array_sum(array_column($v['notice_size'], 'size_qty'));
                    }
                    if (!isset($type_id) || $type_id==1) {
   
                        //null 或 板房
                         $res[$k]['count_qty'] = $pattern;
                    }
                    else{
   
                        // 样品
                        $title = '打样组';
                        $res[$k]['count_qty'] = $sample;
                    }

                }

                return response()->json(["code" => 100 ,"message" => "成功",'list'=> $res]);
            }
            else{
   
                return response()->json(["code" => 200 ,"message" => "数据不存在!",'list'=>$res]);
            }
        }catch (\Exception $e){
   
            $status = 300;
            $message = $e->getLine().$e->getMessage()
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值