[cgiapp] Serve Algorithmically generated PDF

jerry jerry at tr2.com
Thu Dec 7 17:50:05 UTC 2023


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



More information about the cgiapp mailing list