Below is the code for export HTML page to PDF using jquery. All is working properly except I get Black Background colour in the content part of the grid . How to remove this Black colour from the grid content part. I have tried different Js and solutions but either CSS is not applied or if it's applied getting this error.
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/0.9.0rc1/jspdf.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script>
$(document).on("click", "#exporttopdf", function () {
var cache_width = $('.main-sec').width(); //Criado um cache do CSS
var a4 = [595.28, 841.89]; // Widht e Height de uma folha a4
// $(".main-sec").width((a4[0] * 1.33333) - 10).css('max-width', 'none');
// Aqui ele cria a imagem e cria o pdf
html2canvas($('.main-sec'), {
onrendered: function (canvas) {
//var src = canvas.toDataURL("image/png");
var img = canvas.toDataURL("image/jpeg", 1.0);
// var img = canvas.toDataURL("image/png");
//var doc = new jsPDF({ unit: 'px', format: 'a4' });//this line error
var doc = new jsPDF('landscape'); // default is portrait
// doc.addImage(src, 'PNG', 20, 20);
doc.addImage(img, 'JPEG', 20, 20);
doc.save('GridData.pdf');
//Retorna ao CSS normal
$('.main-sec').width(cache_width);
}
});