![]() |
Output byte array as PDF from javascript
Hi all
I have the following ajax call from a webpage. The url points to a webservice (C#) which returns a PDF file as a byte array. How do I output the byte array (in the variable 'result') as a PDF for the user to save using javascript? Code:
$.ajax({ |
you need to turn your array into a string, which i can't advise on without seeing an example server response.
once you have a binary string, it's easy enough to download in newer browsers: Code:
function download(strData, strFileName, strMimeType){you syntax would be something like Code:
download( result.chars.join(""), report.pdf", "application/pdf");at this point, only chrome will respect the filename, with firefox adding support in feb or april. It still will download correctly without the file-name, but you have to rename it on the OS, something which is not always user-friendly. see https://github.com/dcneiner/Downloadify for an IE-friendly version that uses flash. |
| All times are GMT +1. The time now is 11:32 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.