× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




Hello,


Can I push a PDF file out to a web browser?

Yes.

I wrote the following RPG program thinking it would work but I get garbage.

A few thoughts:

a) I see no advantage to using CGIDEV2 for this. You might as well simply write the PDF document as-is to standard output.

b) You need to make sure that the content-type for the PDF tells the web browser that the data is in PDF format. In addition to that, certain versions of Internet Explorer will totally ignore the content-type and expect your URL to end in ".pdf" in order for it to think it's a PDF document. So, keep that in mind -- for things to work correctly, you want BOTH the content type and the extension to be correct.

c) You need to pay close attention to the ASCII/EBCDIC translation. If you want to send it out in binary mode (which would probably be the best way) you'll want to make sure that the CGI conversion mode is set to binary, and also that you've opened the stream file in binary mode. This means that you have to manually do the EBCDIC/ASCII conversion for any other data besides the contents of the PDF itself.

If you want to do it in EBCDIC mode (which is the way that most iSeries web servers are configured) you'll have to be sure that the PDF data that you write out is in EBCDIC and that when it's translated, it'll be translated into the correct ASCII characters. PDF files are not meant to be translated, they're meant to be binary, so this could very easily be problematic if the translation tables don't give you the exact same results in both directions.

We are wanting to dynamically produce the PDF and then push to the user.
The main reason I wanted to push it out was so that I could delete the PDF
as soon as they are done.  Am I going about this the wrong way?

No, I'd do what you're doing. I'd push the PDF out of my CGI script so that I can delete it immediately.


But, I wouldn't try to load the PDF into CGIDEV2's HTML buffers. That seems memory-intensive, and opens the potential for CGIDEV2 to try to "help" you by performing translation for you. I'd return the results directly with the QtmhWrStout() API.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.