On PC it works correctly, but when I try it on mobile I only get a button with the text “Open” but when I press it nothing happens.
I’ve already tried it in several browsers and they all give the same result.
This is the function I use:
async function frmMostrar(idPDF){
$(cargador__).attr('style', 'display: flex;');
await fetch(`/obtenerInformeFinalDrive`, {
method: 'POST',
body: JSON.stringify({ idPDF: idPDF }),
headers: { "Content-Type": "application/json", "X-CSRF-TOKEN": xcsrftoken_ },
})
.then(response => {
if (!response.ok) {
throw new Error('No se pudo recuperar el PDF');
}
return response.blob();
})
.then(responseBlob => {
const reader = new FileReader();
reader.onload = () => {
const byteArray = new Uint8Array(reader.result);
const pdfBlob = new Blob([byteArray], { type: 'application/pdf' });
const pdfUrl = URL.createObjectURL(pdfBlob);
const iframe = document.createElement('iframe');
iframe.src = pdfUrl;
iframe.height = '100%';
iframe.width = '100%';
if (!alertify.modal_informe_final) {
alertify.dialog("modal_informe_final", function() {
return {
main: function(message) {
this.message = message;
},
prepare: function() {
this.setContent(this.message);
}
};
});
}
const modal = alertify.modal_informe_final(iframe).set({ onclosing:function(){}}).set({title: 'Informe final'}).maximize();
const modalContainer = modal.elements.modal;
modalContainer.classList.add('modal_informe_final');
};
reader.readAsArrayBuffer(responseBlob);
})
.catch(error => {
console.error('Error al recuperar PDF:', error);
});
$(cargador__).attr('style', 'display: none;');
}
Movil :
PC: