node.jsexpresspdfnode-streams

Save Octet-stream data as PDF file in javascript


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.