Save Octet-stream data as PDF file in javascript

Issue

Scenario 1:

Need to convert the below mentioned stream data into file in nodejs

Stream data sample: https://gist.github.com/sriramgroot/33e6e4934081f3d1b9d70c88873f2ad9


Scenario 2:

Need to convert the below mentioned stream data into file in browser using reactjs framework

Stream data sample: https://gist.github.com/sriramgroot/33e6e4934081f3d1b9d70c88873f2ad9


Response Header

enter image description here

Note: Final output should be a PDF file and it should be blank document

Solution

Found a solution for saving the file, and it if possible in Scenario 1.

  1. In Octet-stream you will be receiving the response as “Encoded Binary Data”
  2. Your need to convert the response data into “Decoded Base64 String”
  3. Finally save it as PDF

Also we can use NPM package – Base64toPDF for making the listed process as automated.

Answered By – Sriram Karthick

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published