Page 1 of 1

PDF download through the Web Interface

Posted: Fri Aug 07, 2009 12:25 pm
by ConvertFromOldNGs
by skipton >> Thu, 18 Sep 2003 19:50:05 GMT

A requirement for our Jade 6 web interface is to allow a user to download or view pre-generated PDF documents from their browser eg Bank Statements. These documents need to be session secure, such that we don't want to store them on the webserver (and use links), rather we were hoping to stream the file back as we do for the generated HTML pages.

How do we achieve this using Jade? Is it a case of overriding the standard response message and manipulating the response header to let the browser know it's a PDF?

Any help much appreciated.

John
www.jbssolutions.co.uk

Re: PDF download through the Web Interface

Posted: Fri Aug 07, 2009 12:25 pm
by ConvertFromOldNGs
by allistar >> Fri, 19 Sep 2003 7:47:04 GMT

I assume you are using the jadhttp.dll technology. From what I am aware you can't stream back binary data using that (unless it has changed). Having said that you should be able to set up a link that points to a jadhttp.dll request that actually spits back the pdf, so long as you set the content-type in the HTTP headers correctly. As long as the MIME type is set correctly it should work.

Allistar.

------------------------------------------------------------------
Allistar Melville
Software Developer, Analyst allistar@silvermoon.co.nz
Auckland, NEW ZEALAND

Silvermoon Software
Specialising in JADE development and consulting
Visit us at: http://www.silvermoon.co.nz
*NEW* Simple web access to Jade at: www.silvermoon.co.nz/jhp.html ------------------------------------------------------------------

Re: PDF download through the Web Interface

Posted: Fri Aug 07, 2009 12:25 pm
by ConvertFromOldNGs
by Allistar Melville >> Sun, 19 Oct 2003 21:47:57 GMT

Hi again,
JHP has been extended to allow any type of data to be returned from the JADE database. It used to allow returning of HTML only, but now you can output images that come straight from the JADE database, or pdf files, zip files, etc. These files can come either from the database or can be automaticalky generated by your Jade code (it doesn't really matter as all you are returning to the browser - through JHP - is binary data).
This has been made possible by allowing HTTP headers to be added and modified, and in this case you would modify the content-type header to be image/jpeg etc.

A small example that outputs an image from Jade is:

<?jhp
vars
file: File;begin

create file transient;
file.fileName := "c:\somefile.jhp";
file.kind := file.Kind_Binary;
echo(file.readBinary(file.fileLength()).String);
addHTTPHeader("Content-Type", "image/jpeg");
epilog
delete file;
end;
?>

This example gets an image off the disk by JADE, but it could have easily returned a binary from an object in the JADE database as well.

This could also be used to easily allow .pdf files to be returned to the browser from the JADE database. This is also secure in the sense that you didn't want a file stored on the webserver anywhere, and using this they aren't.

I hope this helps,
Allistar.

------------------------------------------------------------------
Allistar Melville
Software Developer, Analyst allistar@silvermoon.co.nz
Auckland, NEW ZEALAND

Silvermoon Software
Specialising in JADE development and consulting
Visit us at: http://www.silvermoon.co.nz
*NEW* Simple web access to Jade at: www.silvermoon.co.nz/jhp.html ------------------------------------------------------------------