Here is My code for download PDF from a jqgrid. I call this js page in My page. pdfExport is my button Id.
$(document).ready(function () {
$("#pdfExport").click(function () {
//alert("clicked");
//alert($("#jqxgrid1").jqxGrid);
var pdf = new jsPDF('p', 'pt', 'letter');
source = $('#tab_customers')[0]; //table Id
specialElementHandlers = {
'#htmlexportPDF': function(element, renderer) {
return true
}
};
margins = { //table margins and width
top: 80,
bottom: 60,
left: 40,
width: 100,
height: 200
};
pdf.fromHTML(
source,
margins.left,
margins.top, {
'width': margins.width,
'elementHandlers': specialElementHandlers
},
margins);
var gridContent = $("#jqxgrid1").jqxGrid('exportdata', 'html');
var filtercontent1 = '
Visit Type:- | Camp Name:- | Time Duration:- |
---|
'
pageContent =
'<!DOCTYPE html>\n' +
'<html>\n' +
'<head>\n' +
'<meta charset="utf-8" />\n' +
'<title>camp schedule report</title>\n' +
'</head>\n' +
'<body>\n' + filtercontent1 + '\n' + gridContent + '\n</body>\n</html>';
//filtercontent += gridContent;
console.log(pageContent);
pdf.fromHTML(pageContent, 15, 15, {
'width': 270,
'elementHandlers': specialElementHandlers
});
pdf.save('CampScheduleReport1.pdf');
});
});
What I have tried:
Same code work for my another page, but here I can't find the error. so plz fixed it or send some new logic for it..
Regards
Bigyan Sahoo