Skip to content

Instantly share code, notes, and snippets.

@timneutkens
Created November 25, 2016 11:37
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save timneutkens/f5eaa9f94cf4e1152149801054e6967c to your computer and use it in GitHub Desktop.
Save timneutkens/f5eaa9f94cf4e1152149801054e6967c to your computer and use it in GitHub Desktop.
Save PDF using javascript (isomorphic-fetch and file-saver)
import fetch from 'isomorphic-fetch'
import { saveAs } from 'file-saver'
fetch('/url/with/pdf', {
headers: {
'Content-Type': 'application/pdf'
},
responseType: 'blob'
}).then(response => response.blob())
.then(blob => saveAs(blob, 'test.pdf'))
@dlplenin
Copy link

Thanks

@andyfaizan
Copy link

Thanks!

@NdauwaRafael
Copy link

Saved me a lot of time and research. Thanks bunch

@nikpros
Copy link

nikpros commented Apr 6, 2021

Спасибо

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment