1

I'm trying to generate a pdf from a twig that's modified in the client side. To do so I'm sending the html document to the server through AJAX but that's not possible since I'm receiving a binary document that can't be handled by JavaScript. Using a simple link neither is valid since I have to send the current twig state... Any suggestions?

Thanks everybody.

Dimitri Dewaele
  • 10,311
  • 21
  • 80
  • 127
Hexen
  • 53
  • 2
  • 14
  • Do you want to [render a pdf from bytestream in ajax response](http://stackoverflow.com/questions/16996743/how-to-render-a-pdf-from-bytestream-in-ajax-response)? – ferdynator Sep 11 '14 at 12:57
  • Not exactly. Knp snappy bundle request an URL to generate the PDF file from there. I'm trying to supply it the html document, that has been modified by the client, to see if that works, but I'm not sure of that. – Hexen Sep 11 '14 at 13:04
  • I finally tested, and yes, I'm receiving a bytestream in ajax response. I have seen the post on your comment, but pdf.js also needs a URL to generate pdf, right? – Hexen Sep 12 '14 at 10:21
  • Maybe try the code the user added as _Update_ to his question. I can't try it here myself but he says it's working – ferdynator Sep 12 '14 at 10:23
  • Tryed the updated code you have mentioned without ";base64" since It isn't working with that, I get the pdf viewer opened but the pdf isn't loaded. – Hexen Sep 13 '14 at 09:50
  • Examine the js here, it does almost the same and has choices for saving result, loading to a new window or displaying inline as embed. http://www.cloudformatter.com/CSS2Pdf – Kevin Brown Sep 14 '14 at 03:42

1 Answers1

1

Examine the js here, it does almost the same and has choices for saving result, loading to a new window or displaying inline as embed. cloudformatter.com/CSS2Pdf

The solution gived by Kevin Brown was perfect.

Hexen
  • 53
  • 2
  • 14