Skip to content

Instantly share code, notes, and snippets.

@oleg-am
Forked from timneutkens/index.js
Created September 21, 2017 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oleg-am/92a1e777cbf0d1cbd84d0c08ced854ce to your computer and use it in GitHub Desktop.
Save oleg-am/92a1e777cbf0d1cbd84d0c08ced854ce 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'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment