Olá! Recebo um base64 de um pdf de uma API. Preciso renderizar esse PDF em tela, ao invés de baixar.
O PDFMAKE tem algumas funções de getBlob, getBuffer, etc. ou até mesmo getBase64.
Alguém já gerou pdf com alguma dessas funções?
Olá! Recebo um base64 de um pdf de uma API. Preciso renderizar esse PDF em tela, ao invés de baixar.
O PDFMAKE tem algumas funções de getBlob, getBuffer, etc. ou até mesmo getBase64.
Alguém já gerou pdf com alguma dessas funções?
Você pode gerar o base64 direto num iframe, por exemplo:
<iframe src="data:base64...">
fonte: https://stackoverflow.com/a/40674644
Ou tentar isso:
var Divider =
'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD//gAfQ29tcHJlc3NlZCBieSBqcGVnLXJlY29tcHJlc3P/2wCEAAQEBAQEBAQEBAQGBgUGBggHBwcHCAwJCQkJCQwTDA4MDA4MExEUEA8QFBEeFxUVFx4iHRsdIiolJSo0MjRERFwBBAQEBAQEBAQEBAYGBQYGCAcHBwcIDAkJCQkJDBMMDgwMDgwTERQQDxAUER4XFRUXHiIdGx0iKiUlKjQyNEREXP/CABEIAAQCfgMBIgACEQEDEQH/xAAXAAEBAQEAAAAAAAAAAAAAAAABAgAI/9oACAEBAAAAAO/dtnbSEhMhISSEkhJISaqu6qrqqqmqpadnCIm2ztv/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/9oACAECEAAAAAAAAAAA/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAxAAAAAAAAAAAP/EAB8QAQACAgMAAwEAAAAAAAAAAAAVFgEUBhETAgUSIP/aAAgBAQABCADp+Hk8Wu1Wm0UejkYi0UiEOhkIg0CgFfV1XFbVlWFXVVVFSVFUFOU1S1KUlR1GUZjhDHCumOGqexxLpVFWVljjauq8x9AgkIx9L0h0Sx9WjEaj2i0mm1Ws13g8Xk834Y+Dp06/n//EACIQAAEDBAMBAQEBAAAAAAAAAAAFBpQEk+HiAgOSkQGVIP/aAAgBAQAJPwA5cvp2c/p29no7+70VPf7Kqo9lZU3Cuq7hX1l3AoVt3Ao117ApV97Ap197AqKF/ArKN/ArqUjAsKcjAsqkjAtKsnAtq0nAuK8rAvLErAvrMrA4FqXqOFbl6jiXJeo5F2ZqOVdmajmXpuo51+bqOhwTdR0uGdqOpxTtR2OOfqO1yT9R3OWfqO9zT9R4Of8Aoajxc/8AQ1He5Z+o7HHP1HU4p2o6HBN1HMvzdRyLszUca5M1HCtS9RfWZWBdV5WBcVpOBaVZOBYVJGBXUpGBVUb+BUUL+BTr72BRrr2BQrbuCvrLuCuq7uCsqrhV1Nwqqj2VPf7O/u9Hf2+ju7PR29no7Of07Of05cvpy5H7+n7+/wCv/8QAFBEBAAAAAAAAAAAAAAAAAAAAUP/aAAgBAgEBPwAj/8QAFBEBAAAAAAAAAAAAAAAAAAAAUP/aAAgBAwEBPwAj/9k='
var HorizontalDivider = {
image: Divider,
margin: [0, 0, 0, 0],
height: 1,
width: 550,
}
var dd = {
pageSize: 'A4',
content: [
{
text: `Date Sent: xx-xx-xxxx`,
alignment: 'right',
fontSize: 10,
//font: 'Montserrat',
color: '#000000',
},
{
text: `Date Received: xx-xx-xxxx`,
alignment: 'right',
fontSize: 10,
//font: 'Montserrat',
color: '#000000',
margin: [0, 5, 0, 0],
},
HorizontalDivider,
],
}
Fonte: https://github.com/bpampuch/pdfmake/issues/2146#issuecomment-738881034