html2pdf.js
html2pdf.js copied to clipboard
Line breaks don't work when generating Blob
Hi,
I'm trying to generate a PDF with some line-breaks.
I spread some <div class="html2pdf__page-break"/> across my HTML.
When I look into the preview (the window that appears when I try to generate the PDF), the line-breaks work fine.
But when I export it as a blob and save it on my server (S3), there are no line-breaks. Am I missing something here?
Here is my code:
const pdf = await html2pdf()
.set({ pagebreak: { avoid: ['.avoid'] }, html2canvas: { scrollX: 0, scrollY: 0 }})
.from(pdfContent)
.toPdf()
.get('pdf')
.then((pdf) => pdf);
const preBlob = pdf.output('blob');
const formData = new FormData();
formData.append('report', preBlob, 'my-file.pdf');
Thanks
Hi. I worked in a similar problem 1 month ago and remove class and set the all custom styles on " style=" " " directive works for me.
Try this one