html2pdf.js
html2pdf.js copied to clipboard
Background color is not interpreted correctly
Hi, the background color is not interpreted correctly. For example, when the background color is white (#FFFFFF), it is interpreted as #FDFDFD. I would like to know how to get a completely white background. Does anyone know what can happen?
html2pdf().from(innerHtml).set({
margin: 1,
filename: fileName+'.pdf',
image: { type: "jpeg", quality: 1},
jsPDF: {orientation: 'portrait', unit: 'in', format: 'letter', compressPDF: false},
pagebreak: {mode: ['avoid-all']}
}).save().then(function () {
console.log("finish!");
});
Thanks! web.pdf
So the html element is:
<div style="background-color: #FFFFFF" >
Content of this pdf
</div>
PDF: #FDFDFD
So the html element is:
<div style="background-color: #FFFFFF" > Content of this pdf </div>PDF: #FDFDFD
Right!
Hi @jgrDev, that's interesting! Can you show me how you're setting the styles? If it truly is <div style="..."> then I'm surprised it's not working, but there are other possible causes if you're using a stylesheet.
Hi @eKoopmans! The styles are apply through style sheets:
index.html:
<div class="box">...<div>
app.css:
.box{
background-color: #FFFFFF;
}
I have tried with styles in line, but the result is the same. Thanks!!
any progress? got same issue.It seems will happen to last node. for me, the background turns to #fdfdfd Dashboard Report(20190905) (6).pdf
I had exactly the same problem, I solved it by decreasing the scale in the options.
I'm seeing the same issue with colors not loading. For example, I have
The solution from @Bagu3tte saved my day 90% of the css applied correctly after turning down scale to 1
I'm seeing the same issue with colors not loading. For example, I have
- items rendering down the page all with the same styling from a stylesheet, but it seems to run out of steam and the
- elements just lose all their styling. Is there a solution for this?
I'm seeing the same thing! I have a card with a background color that doesn't render at the bottom of the PDF but does render at the top!