SHARE
TWEET

Untitled

a guest Jun 20th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. params =
  2.     "graphics": "<h1>test</h1>"
  3.  
  4. d3.xhr(pdf_url.toString())
  5.     .header("X-CSRFToken", document.csrf_cookie)
  6.     .header("Content-Type", "application/json")
  7.     .header("Accept", "application/pdf")
  8.     .post JSON.stringify(params), (error, pdf_data) ->
  9.         if error
  10.             console.log(error)
  11.         else
  12.             a = document.createElement("a")
  13.             file = new Blob [pdf_data.response], "type": "application/pdf"
  14.             url = URL.createObjectURL(file)
  15.             a.href = url
  16.             a.download = "#{params['title']} #{params['filter']}.pdf"
  17.             document.body.appendChild(a)
  18.             a.click()
  19.             setTimeout ->
  20.                 document.body.removeChild(a)
  21.                 window.URL.revokeObjectURL(url)
  22.             , 0
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top