Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Creating a file in Javascript using the available Bytestream

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any way to create a file (eg: a Pdf) in Javascript by setting its mime type,title, content, etc and display it in the browser with the option to download?

I have a Base64 bytestream of a pdf in the javascript and I am using it to display the pdf to the user by:

document.location.href = 'data:application/pdf;base64,' +data;
which opens the file in a new window (it works in all browsers except IE as it has url restrictions) and the file is not downloadable in all browsers. IE is the primary browser for testing my application so this is a big issue.

Option of using a backend technology like Java to create a file and send it as the response is ruled out as I have an ABAP backend and it can give me only the bytestream. Many suggested using jsPdf but jsPdf creates the content from javascript (like setting line by line info and formatting) and uses it. But as I already have all the data and formatting I need I am not able to use it.

Here is the question I asked for byte conversion and display of pdf in the webpage in stackoverflow, that got answered, for additional info:
http://stackoverflow.com/questions/11131789/how-to-convert-hexadecimal-byte-stream-in-the-form-of-string-to-actual-bytestrea

I have done my best in searching for the solution but couldn't able to find one yet. Please help. I will be thankful.

Regards, Riswan
 
I will suppress my every urge. But not this shameless plug:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic