PDF download through the Web Interface

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

PDF download through the Web Interface

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:25 pm

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

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: PDF download through the Web Interface

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:25 pm

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 ------------------------------------------------------------------

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: PDF download through the Web Interface

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:25 pm

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 ------------------------------------------------------------------


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 15 guests

cron