2
I am generating PDF’s of the data I have in a table in my client, send the data to the server and there is generated PDF. After it is ready, the PDF download takes place, and it is at this stage of the process that it corrupts.
However, if before I download it I open it manually, it opens without any problems, with the same data that was in the table, IE, it is corrupting when I download, follow the codes below:
Server:
let filePath = "C:/Projetos/Relatorios/pdfs/Tabela.pdf";
let fileName = 'PDF.pdf';
res.download(filePath, fileName);
Client:
axios({
method: 'post',
url: '/server/gerarpdf',
responseType: 'arraybuffer',
data: this.pessoas
})
.then(function (response) {
let blob = new Blob([response.data], {type: 'application/pdf'})
let link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.download = 'TabelaTeste.pdf'
link.click()
})
If anyone knows what is corrupting the PDF thank you...
Vlw to share with! ;)
– Bruno Rigolon
I’m happy to help, because I’ve already received a lot of help here, I just want to give back in the best way
– LeonardoEbert