I have an application which has the purpose of converting a webpage to dataURL, and then converting that dataURL to a PDF. The dataURL conversion is being done with html2canvas and the PDF conversion is being done with JSPDF.
Because JSPDF requires JPEG I'm converting the dataURL as a jpeg. This leads to an issue because JPEGs seem to not process transparent backgrounds properly which is leaving me wit ha very ugly black background PDF. I've looked around for solutions to this problem but nothing I've done so far seems to work
In theory I should just be able to set the html2canvas background property to #fff, but this or any other colour have no effect on the output. Can anyone think of any other reason why my my dataURL conversion would still have a black background? Oddly enough it works fine when I access the body element, but when I access the container div that wraps the same portion, this problem comes up
Here is the Jquery function I'm using to perform this action.
$(document).ready(function() {
$("#testButton").click(function() {
html2canvas($("#container"), {
allowTaint: false,
logging:true,
background:'#fff',
onrendered: function(canvas) {
var data = canvas.toDataURL('image/jpeg',1.0);
window.open(data);
var doc = new jsPDF();
doc.addImage(data,'JPEG',15,40,200,200);
doc.output('save', 'testingtwo.pdf');
}});
});
});
Does anyone know why the background would remain black?