Php mpdf在邮递员中工作,但不在chrome中工作

Php mpdf在邮递员中工作,但不在chrome中工作,php,angularjs,mpdf,Php,Angularjs,Mpdf,我正在尝试使用mpdf生成和下载pdf。在《邮递员》中效果很好,但我一试chrome就不起作用了 这是我的角休息 $http({ url: 'http://localhost:8080/services/generatePDF?uniqueID=INV0005', method: 'GET', headers: { 'securityToken': '123', 'Content-Type': 'application/json'

我正在尝试使用
mpdf
生成和下载pdf。在《邮递员》中效果很好,但我一试chrome就不起作用了

这是我的角休息

 $http({
    url: 'http://localhost:8080/services/generatePDF?uniqueID=INV0005',
    method: 'GET',
    headers: {
        'securityToken': '123',
        'Content-Type': 'application/json'
    }
 }).then(function(res) {
    console.log(res)
 }, function(ress) {
    console.log(res)
 })
这是我的php代码

header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="filename.pdf"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');


$pdf= new mPDF(); 
$pdf->SetHTMLFooter('<span style="color:#a1a1a1;font-size:12px;padding-left:100px;"> powered by 12thdoor </span>');
$pdf->WriteHTML($stylesheet,1);
$pdf->WriteHTML($body,2);
$pdf->Output('filename.pdf', 'D'); 
标题('Content-type:application/pdf');
标题('Content-Disposition:inline;filename=“filename.pdf”');
标题(“内容传输编码:二进制”);
标题('Accept-Ranges:bytes');
$pdf=新的强制性公积金计划();
$pdf->SetHTMLFooter(‘由第12扇门供电’);
$pdf->WriteHTML($stylesheet,1);
$pdf->WriteHTML($body,2);
$pdf->Output('filename.pdf','D');
这就是我得到的错误

bc81
%PDF-1.4
%    
3 0 obj
<</Type /Page
/Parent 1 0 R
/MediaBox [0 0 595.280 841.890]
/TrimBox [0.000 0.000 595.280 841.890]
/Resources 2 0 R
/Group << /Type /Group /S /Transparency /CS /DeviceRGB >> 
/Contents 4 0 R>>
endobj
4 0 obj
<</Filter /FlateDecode /Length 1334>>
stream
x  Y n F g} 
bc81
%PDF-1.4
%    
30 obj
>
endobj
40 obj
流动
x Y n F  g}
我已经试过在angularjs中使用
application/pdf
content-type头,但仍然不起作用。谢谢

如何使用angularjs下载二进制文件 下载二进制文件时,设置
responseType
非常重要:

$http({
    url: 'http://localhost:8080/services/generatePDF?uniqueID=INV0005',
    //SET responseType
    responseType: 'blob',
    method: 'GET',
    headers: {
        'securityToken': '123',
        'Content-Type': 'application/pdf'
    }
 }).then(function(response) {
    console.log(response.data);
 }, function(response) {
    console.log(response.status);
 })
如果省略了
responseType
,则XHR API默认将编码文本转换为会损坏PDF和图像文件的文本


有关更多信息,请参见

谢谢兄弟。我创建了一个新函数,用于在响应后手动下载blob文件。现在它可以正常工作了。你为我节省了很多时间。干杯