Laravel 3控制器上的TCpdf [英] Tcpdf on Laravel 3 controller

查看:106
本文介绍了Laravel 3控制器上的TCpdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好.我正在尝试使用Tcpdf库和捆绑包生成Pdf.我在这样的控制器上测试了该库的基本用法:

Good morning. I'm trying to generate a Pdf with Tcpdf library and bundle. I tested the basic usage of the library on a controller like this:

public function get_reporte_grupos(){           
    $pdf = new Tcpdf();
    $pdf->AddPage();
    $pdf->SetFont('times','B',16);
    $pdf->Cell(40,10,'Hello World!');
    $pdf->Output('example_001.pdf', 'I');
}

我的输出就像pdf文件的de二进制文件:

And my output is like the de binary of the pdf file:

%PDF-1.7%8 0 obj<< /类型/页/父项1 0 R/最后修改 (D:20130725101953-04'30')/资源2 0 R/MediaBox [0.000000 0.000000 595.276000 841.890000]/CropBox [0.000000 0.000000 595.276000 841.890000]/BleedBox [0.000000 0.000000 595.276000 841.890000]/TrimBox [0.000000 0.000000 595.276000 841.890000]/ArtBox [0.000000 0.000000 595.276000 841.890000]/内容9 0 R/旋转0/组<< /类型/组/S/透明/CS/DeviceRGB >>/Annots [7 0 R]/PZ 1 >> endobj 9 0 obj<>流xSN0 + [{qW(-ꩀ%^ H(Uh8R().....依此类推.

%PDF-1.7 % 8 0 obj << /Type /Page /Parent 1 0 R /LastModified (D:20130725101953-04'30') /Resources 2 0 R /MediaBox [0.000000 0.000000 595.276000 841.890000] /CropBox [0.000000 0.000000 595.276000 841.890000] /BleedBox [0.000000 0.000000 595.276000 841.890000] /TrimBox [0.000000 0.000000 595.276000 841.890000] /ArtBox [0.000000 0.000000 595.276000 841.890000] /Contents 9 0 R /Rotate 0 /Group << /Type /Group /S /Transparency /CS /DeviceRGB >> /Annots [ 7 0 R ] /PZ 1 >> endobj 9 0 obj <> stream xSN0+[{qW(-ꩀ%^H(Uh8R().. and so on.

我在这里想念的是什么?我不想使用html2pdf,因为我生成的文件种类太繁琐,我必须控制分页符才能进行一些数学运算.那我在这里想念的是什么?

What I'm missing here? I don't wanna use html2pdf because the kind of files I'm generating is way too extense and I have to get control of the page break in order to do some maths. So what I'm missing here?

预先感谢

推荐答案

哦,我要删除问题,但是如果有人遇到同样的问题,我会回答.在控制器上更换

Oh well, I was gonna to delete the question, but I'll answer if someone comes with the same problem. On the controller replace

$pdf->Output('example_001.pdf', 'I');

使用

return Response::make($pdf->Output('example_001.pdf', 'I'), 200, array('Content-Type' => 'application/pdf'));

然后您将获得pdf文件.

And you'll get your pdf file.

这篇关于Laravel 3控制器上的TCpdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆