views:

225

answers:

1

My client side application is using jqgrid that requests the server side, which in its turn queries MySQL and sends back the resultSet in XML format.

I'm willing to add the export to PDF functionality in the client side And I was stumped on how to go about it.

Please any indications?

+3  A: 

The export to pdf should be done on the server side. For something to be done on the client side, first the software to do it must exist there and then you should have permissions to use it. Browsers can't export to pdf by default. What you can do is have a link that sends the request to a page, which generates the needed data, exports it to pdf and writes it out. Something code like this would exist on that page (assuming you are using PHP as the server side language):

// We'll be outputting a PDF
header('Content-type: application/pdf');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');

// Code to create the pdf goes here...

// The PDF source is in original.pdf
readfile('original.pdf');

Source for above: http://php.net/manual/en/function.header.php

aip.cd.aish