[lug] CGI Generated PDFs and MS Explorer 5.5 Problems...

Ryan Kirkpatrick linux at rkirkpat.net
Tue Mar 27 21:49:58 MST 2001


On Thu, 22 Mar 2001, Michael J. Pedersen wrote:

> On Thu, Mar 22, 2001 at 07:08:29AM -0700, Ryan Kirkpatrick wrote:
> > 	I have a CGI program that dynamically generates PDF files and
> > returns them to the user's web browser for it to display. This works
> 
> While I have no idea as to the cause of this problem, I do have a request:
> Is there any chance you could post the CGI someplace? I could use it quite
> nicely, and think it would make a decent addition to a code library (even if
> all I can ever use it for is reference on how to generate a PDF file).

	Hmm... It is nothing too special, because it cheats in generating
the dynamic PDF files... It actually does search and replace on a
postscript file (which is text based of course) and then converts the
resulting file into PDF with ps2pdf in real-time. The site does not see
that much traffic so this is a usable solution. The postscript file is of
course created from M$ Word via a HP LaserJet Postscript printer
driver. :)
	Like I said, I cheated and the code is nothing all that exciting
at all. 

> The only idea I have for your problem sounds like it's already been done: Have
> the CGI generate the pdf file, and save it, then see what happens when the
> saved pdf gets served.

	That is exactly what is happening... I open the postscript file,
search and replace line by line, writing out to a temp file. Then I open
the temp file reading (after closing it from writing of course), print the
HTTP content headers, and then print the PDF file, both to STDOUT, which
is served back to the web browser.

> Here's a possible idea, though: Have your CGI generate a static pdf file into
> a specific directory. Then, once done, the CGI will send a redirect to the
> client, redirecting to the static pdf file. It might work.

	I would like to avoid that solution, it is a bit of kludge, but
may be my only choice. :(

---------------------------------------------------------------------------
|   "For to me to live is Christ, and to die is gain."                    |
|                                            --- Philippians 1:21 (KJV)   |
---------------------------------------------------------------------------
|   Ryan Kirkpatrick  |  Boulder, Colorado  |  http://www.rkirkpat.net/   |
---------------------------------------------------------------------------




More information about the LUG mailing list