Open PDF Base64

Asked

Viewed 1,014 times

1

I have an application that generates a PDF in bytes and converts it to ToBase64String and sends astravés of a JSON for javascript to open, but on Chrome it cannot read this file and present the PDF

inserir a descrição da imagem aqui

   $.post('/RelatoriosGerais/GerarPDF/', { CategoriaRelatorio: 1 }, function (data) {
                if (data.status = true) {

                    let Pdf = 'data:application/pdf;base64,' + data.arrayByte;
                    window.open(Pdf, '_blank');
}

whereas data.arrayByte is base 64 which is returned via JSON

NOTE: Firefox works

  • I know the question is old, but I believe that Uri Scheme date has limit, that varies between browsers, in this case it seems to me that Blob could be better, because the limit is higher, ooutra output would simply record in real files.

1 answer

0

  • The definition is correct 'data:application/pdf;base64,' + data.arrayByte;.

Browser other questions tagged

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