Closed rogerio-pereira closed 1 year ago
Solved. Changed method beforeDownload
async beforeDownload ({ html2pdf, options, pdfContent }) {
let pdfBlobUrl = await html2pdf()
.set(options)
.from(pdfContent)
.toPdf()
.get('pdf')
.then((pdf) => {
const totalPages = pdf.internal.getNumberOfPages()
for (let i = 1; i <= totalPages; i++) {
pdf.setPage(i)
pdf.setFontSize(10)
pdf.setTextColor(150)
pdf.text('Page ' + i + ' of ' + totalPages, (pdf.internal.pageSize.getWidth() * 0.88), (pdf.internal.pageSize.getHeight() - 0.3))
}
})
.save()
.output('bloburl')
let res = await fetch(pdfBlobUrl);
let blobFile = await res.blob();
}
Variable blobFile is the pdf file
Describe the bug How can i get the pdf BLOB after pagination?
To Reproduce Pdf with pagination is being downloaded normally, i need a way to get the pdf blob, so i can send it to backend, to be processed (store in S3, and send it to email). To paginate i'm using
@beforeDownload
, but is required to set the props:enable-download
and:preview-modal
to falsePackage Version e.g. ^1.8.0
Additional context Available method
hasDownloaded
, works, but not when props:enable-download
and:preview-modal
are false (which is required to paginate the file)I need the pagination in this case, because it contains the version of the file