Open PDF Internet Explorer

Asked

Viewed 116 times

1

Good morning, I need to Open PDF of my table at the click button, it is working in all browsers, except in IE, in principle just convert Base64 into something that IE support, automatic, via javascript, more is what I’m not getting.

this is my JS

gerarRelatorio = function() {
    var doc = new jsPDF('l', 'pt');
    var res = doc.autoTableHtmlToJson(document
            .getElementById("tabela"));

    var header = function(data) {
        doc.setTextColor(40);
        doc.setFontStyle('normal');
        doc.setFontSize(11);    
    };

    var options = {
        addPageContent : header,
        theme : 'striped',
        tableWidth : 'auto',
        margin : {
            top : 80
        },
        startY : false
    };

    doc.autoTable(res.columns, res.data, options);

    var data = doc.output('dataurl');
    var fileName = "pdf.pdf";
    if (window.navigator && window.navigator.msSaveOrOpenBlob) {
        var byteCharacters = atob('dataurl');
        var byteNumbers = new Array(byteCharacters.length);
        for (var i = 0; i < byteCharacters.length; i++) {
            byteNumbers[i] = byteCharacters.charCodeAt(i);
        }
        var byteArray = new Uint8Array(byteNumbers);
        var blob = new Blob([byteArray], {type: 'application/pdf'});
        var base64EncodedPDF = data;
        var dataURI = "data:application/pdf;base64," + data;
        window.open(dataURI, '_blank');
        window.navigator.msSaveOrOpenBlob(blob, fileName);
        window.open("data:application/pdf;base64, " + dados, '', 
        "height=600,width=800");
    }
    else {
        x = window.open();
        iframe = x.document.createElement('iframe')
        iframe.width = '100%'
        iframe.height = '100%'
        iframe.frameBorder = 0
        dados = doc.output('dataurl');
        iframe.style = "border: 0"
        iframe.src = 'data:application/pdf;base64' + dados
        x.document.body.appendChild(iframe);
    }
}
  • I took the one that says that in IE Works no longer found solution in my project https://stackoverflow.com/questions/43070627/internet-explorer-fails-opening-a-pdf-string-file-solved

  • Possible duplicate of appear PDF in Internet Explorer

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.