2014-10-02 1 views
0

PDF : API2를 사용하여 즉석에서 PDF를 작성하는 Action ('RenderView') 메소드가있는 컨트롤러가 있습니다.Perl Catalyst : PDF 작성 및 강제 다운로드 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'); 

나는 내가 만든 파일의 존재 여부를 반복적으로 테스트하고 저장 및 발견 된 때를 역할을 수도있을 것 같군요. 그건 내게 아주 엉망인 것 같아.

누구나 더 나은 해결책이 있습니까?

감사합니다, 노아 documentation에서

답변

1

:

$string = $pdf->stringify(); 

돌아 가기 문자열로 문서와 메모리에서 개체 구조를 제거합니다.

+0

매력처럼 작동합니다! 감사! –