<?php namespace AloVoice; $doc = $GLOBALS["document"]; // echo "<PRE>"; var_dump($doc); echo "</PRE>"; ?> <!DOCTYPE html> <html lang="ru"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title><?php echo $doc['title']?> PDF</title> <script> var doc = JSON.parse('<?php echo json_encode($doc)?>'); </script> </head> <body> <div style="height: 98vh; overflow-y: hidden;"> <object> <embed src="" type="text/html" frameBorder="0" scrolling="auto" height="100%" width="100%" id="embed"> </object> </div> <script> document.addEventListener('DOMContentLoaded', function () { laod(doc.pdfUrlMachine, function (b64) { var embed = document.getElementById('embed'); embed.setAttribute('src', b64); }); }); function laod (url, callback) { var xhr = new XMLHttpRequest(); xhr.onload = function() { var reader = new FileReader(); reader.onloadend = function() { callback(reader.result); } reader.readAsDataURL(xhr.response); }; xhr.open('GET', url); xhr.responseType = 'blob'; xhr.send(); } </script> </body> </html>