Base64 representing PDF to blob - JavaScript

后端 未结 2 465
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-25 15:10

I have a Base64 string representing a PDF file. I want to convert it to a file with the Blob object using javascript. After it\'s done i want to save the blob as a PDF file

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-25 15:28

    You have to convert the base64 string back into the original binary data. Using atob is not sufficient, you'll have to run it through a loop and convert it to an array buffer - Convert base64 string to ArrayBuffer
    Then use that to create the blob.

提交回复
热议问题