/* The following javascript code will retrieve the raw tx data for transaction id 54e48e5f5c656b26c3bca14a8c95aa583d07ebe84dde3b7dd4a78f4e4186e713 and convert it into a downloadable PDF document inside of the browser. I would recommended changing the source for downloading the raw transaction data from your own node or source. Examples include: https://indexer.switcha.me/tx/54e48e5f5c656b26c3bca14a8c95aa583d07ebe84dde3b7dd4a78f4e4186e713 */ fetch('https://indexer.switcha.me/tx/54e48e5f5c656b26c3bca14a8c95aa583d07ebe84dde3b7dd4a78f4e4186e713') .then(response => response.text()) .then(data => { var s = data.split("0100000000000000"); var lines = []; for (var i = 1; i < s.length; i++) { lines.push([s[i].slice(6,136), s[i].slice(138,268), s[i].slice(270,400)].join('')); } var pdfString = lines.join('').slice(16,-20); var a = document.createElement("a"); a.href = "data:application/pdf;base64,"+btoa(pdfString.match(/\w{2}/g).map(function(a){return String.fromCharCode(parseInt(a, 16));} ).join("")); a.download = "Bitcoin.pdf"; a.click(); });
Comments