简体   繁体   English

MPDF 57,在Windows中不起作用

[英]MPDF 57, not working in Windows

I have used a particular code to download pdf using "MPDF 57": 我使用特定的代码使用“ MPDF 57”下载pdf:

         ob_start(); 
         ob_clean(); // cleaning the buffer before Output()
         $html = '
         <div style="font-weight:bold;font-size:40px;color:#264664";>Title</div>
         <img  src='.$imgsrc.' name="image1">

            ';

        $mpdf=new mPDF('c','A4');
        $mpdf->WriteHTML($html);
        $mpdf->Output('Chart_'.time().'.pdf','D');
        exit;

I got this code working fine for UBUNTU. 我使这段代码对UBUNTU正常工作。 But it failed in Windows. 但是在Windows中失败了。 When the downloaded file is opened with any reader, it throws error message that file is corrupted. 当使用任何阅读器打开下载的文件时,它会引发错误消息,指出文件已损坏。 What has gone wrong with the code? 代码出了什么问题? I cannot find why this piece of code works only for browsers in Ubuntu OS and not for browsers in windows OS? 我找不到为什么这段代码仅适用于Ubuntu OS中的浏览器而不适用于Windows OS中的浏览器?

My guess is that it's a parse error that Ubuntu can handle but Windows cannot. 我的猜测是,这是Ubuntu可以处理但Windows无法处理的解析错误。 You have two tiny syntax errors. 您有两个微小的语法错误。 First, a semicolon out of place: 首先,分号不合适:

<div style="font-weight:bold;font-size:40px;color:#264664";>Title</div>

Should be: 应该:

<div style="font-weight:bold;font-size:40px;color:#264664;">Title</div>
                                                ---------^

And second, missing quotes around the src attribute: 其次,在src属性周围缺少引号:

<img  src='.$imgsrc.' name="image1" />

Should be: 应该:

<img src="'.$imgsrc.'" name="image1">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM