Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. //Get the document
  2. var xmlhttp=new XMLHttpRequest();
  3. xmlhttp.open("GET","../../documents/get_document.php",false);
  4. xmlhttp.send();
  5.  
  6. var pdf_document = xmlhttp.responseText;
  7.  
  8. var DEFAULT_URL = 'data:application/pdf;base64,' + pdf_document;
  9.  
  10. function base64ToUint8Array(base64) {
  11. var raw = atob(base64); //This is a native function that decodes a base64-encoded string.
  12. var uint8Array = new Uint8Array(new ArrayBuffer(raw.length));
  13. for(var i = 0; i < raw.length; i++) {
  14. uint8Array[i] = raw.charCodeAt(i);
  15. }
  16. return uint8Array;
  17. }
  18.  
  19. //Get the document
  20. var xmlhttp=new XMLHttpRequest();
  21. xmlhttp.open("GET","../../documents/get_document.php",false);
  22. xmlhttp.send();
  23.  
  24. var pdf_document = xmlhttp.responseText;
  25.  
  26. var DEFAULT_URL = base64ToUint8Array(pdf_document);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement