Perl Catalyst:创建并强制下载PDF

Perl Catalyst:创建并强制下载PDF,perl,pdf,download,catalyst,Perl,Pdf,Download,Catalyst,我有一个带有Action('RenderView')方法的控制器,该方法使用PDF::API2动态创建PDF 我不想保存PDF,而是想强制下载对话框。类似于以下伪代码: ... create pdf on-the-fly ... $pdf->saveas($fullPathToFilename); # is there a way to avoid this? binmode STDOUT; $c->res->content_type('application/pdf'); $

我有一个带有Action('RenderView')方法的控制器,该方法使用PDF::API2动态创建PDF

我不想保存PDF,而是想强制下载对话框。类似于以下伪代码:

... create pdf on-the-fly ...
$pdf->saveas($fullPathToFilename); # is there a way to avoid this?
binmode STDOUT;
$c->res->content_type('application/pdf');
$c->res->header( 'Content-Disposition', qq[attachment;filename='$shortFilename'] );
$c->res->header( 'someOtherHeaders' );
... here, stream binary content to client ?? ...
return $self->status_ok( $c, entity => 'PDF' );
我想我可以反复测试a创建的文件是否存在,并在保存和发现该文件时为其提供服务。对我来说,那似乎很笨拙

谁有更好的解决方案

谢谢, 诺亚

来自:


以字符串形式返回文档,并从内存中删除对象结构。

效果很好!谢谢
$string = $pdf->stringify();