[cgiapp] Serve Algorithmically generated PDF
Rhesa "perl" Rozendaal
perl at rhesa.com
Thu Dec 7 18:13:09 UTC 2023
I serve pdf files through cgiapp as well. Here's how my runmode looks like:
sub receipt {
my $self = shift;
my $pdf = '<the raw pdf data>';
$self->header_add( -type => 'application/pdf');
return $pdf;
}
rhesa
On 07/12/2023 18:50, jerry wrote:
> Hello!
>
> I have a CGI::App - based application that I have been writing &
> expanding since 2006. At this time,
> I'm trying to serve PDF data that is algorithmically generated.
> Specifically, I use a fillable form, an
> "FDF" file to create a filled out PDF from a web form.
>
> When I try to have a run mode directly serve a PDF, the browser
> chokes and displays pages of binary garbage. If, OTOH, I create the
> file and then have the user click a separate button to serve it,( not
> a run mode, just an HTML link to the actual file ) the PDF renders
> normally.
>
> I tried specifying PDF in the header:
>
> $cgi->header( -type => 'application/pdf' )
>
> The browser then shows the same garbage, just prefixed by
> "application/pdf".
>
> Here's a snippet of what's seen on the browser:
> ----------snip----------------
> Content-Type: application/pdf; charset=ISO-8859-1 %PDF-1.6 %§ãññ 2 0 obj
> -------- endsnip --------------
>
> Can anybody supply a clue? I can always get these files in a two-step
> process - "generate PDF", and then
> "get PDF", but that's a little hokey, even if I use javascript to only
> create the "get PDF" button when there is actually a PDF to get.
>
> - jerry at tr2.com
>
>
> ##### CGI::Application community mailing list ################
> ## ##
> ## To unsubscribe, or change your message delivery options, ##
> ## visit: http://lists.openlib.org/mailman/listinfo/cgiapp ##
> ## ##
> ## Web archive: http://lists.openlib.org/pipermail/cgiapp/ ##
> ## Wiki: http://cgiapp.erlbaum.net/ ##
> ## ##
> ################################################################
More information about the cgiapp
mailing list