Aug 27th, 2019, 11:30 PM
#1
Thread Starter
Junior Member
set null in empty cell in jspdf autotable
i m using jsPDF auto table plugin
i need to set null in the cell while printing on pdf where html table contain  
here is complete code but its not inserting null
attached file
Attached Files
Aug 27th, 2019, 11:38 PM
#2
Re: set null in empty cell in jspdf autotable
Rather than attaching all the code as a text file, you should post only the relevant code directly, formatted as code for readability.
Aug 27th, 2019, 11:39 PM
#3
Thread Starter
Junior Member
Re: set null in empty cell in jspdf autotable
Code:
<script>
function generate() {
var doc = new jsPDF('l', 'mm', "a4");
var res = doc.autoTableHtmlToJson(document.getElementById("printJS-form"));
// doc.autoTable(res.columns, res.data, { margin: { top: 80 } });
var header = function (data) {
//doc.setFontSize(10);
// doc.setTextColor(0);
//doc.setFontStyle('bold');
//doc.setFillColor(110, 214, 84);
// doc.setFontSize(0)
// doc.
//doc.addImage(headerImgData, 'JPEG', data.settings.margin.left, 20, 50, 50);
// doc.text("Testing Report", data.settings.margin.left, 50);
};
var options = {
tableWidth: 'wrap',
didDrawPage: header,
margin: {
top: 10,
bottom: 40,
left: 1,
right: 1,
//width: 120
},
//bodyStyles: {
// text: { minCellWidth: '10' }
//},
columnStyles: {
0: { cellWidth: 15 }, //frequency
1: { cellWidth: 22}, //task name
2: { cellWidth: 8.5 }, // shift
3: { cellWidth: 10.5}, //range
4: { cellWidth: 7.2 },
5: { cellWidth: 7.2 },
6: { cellWidth: 7.2 },
7: { cellWidth: 7.2 },
8: { cellWidth: 7.2 },
9: { cellWidth: 7.2 },
10: { cellWidth: 7.2 },
11: { cellWidth: 7.2 },
12: { cellWidth: 7.2 },
13: { cellWidth: 7.2 },
14: { cellWidth: 7.2 },
15: { cellWidth: 7.2 },
16: { cellWidth: 7.2 },
17: { cellWidth: 7.2 },
18: { cellWidth: 7.2 },
19: { cellWidth: 7.2 },
20: { cellWidth: 7.2 },
21: { cellWidth: 7.2 },
22: { cellWidth: 7.2 },
23: { cellWidth: 7.2 },
24: { cellWidth: 7.2 },
25: { cellWidth: 7.2 },
26: { cellWidth: 7.2 },
27: { cellWidth: 7.2 },
28: { cellWidth: 7.2 },
29: { cellWidth: 7.2 },
30: { cellWidth: 7.2 },
31: { cellWidth: 7.2 },
32: { cellWidth: 7.2 },
33: { cellWidth: 7.2 },
34: { cellWidth: 7.2 },
// etc
},
tableWidth: 'auto',
headStyles: { minCellHeight: 8, fontSize: 6.5, text: { minCellWidth: 'wrap' } },
bodyStyles: {
minCellHeight: 8, fontSize: 6.5,
margin: {
top: 10,
bottom: 40,
left: 1,
right:1,
//width: 120
minCellWidth: 'auto'
},
}
// startY: doc.autoTableEndPosY() + 20
};
//doc.autoTable(res.columns, res.data, options);
doc.autoTable(res.columns, res.data, options, {
tableLineColor: [189, 195, 199],
createdCell: function(cell, data) {
if (!cell.raw) {
cell.text = 'erum';
}
//var tdElement = cell.raw;
//console.log(tdElement)
//if (tdElement.classList.contains('blank')) {
// cell.text = 'erum'
//}
//if (typeof cell.raw === 'undefined')
//{
// cell.raw.text = "erum";
},
//styles: {
// overflow: 'linebreak', columnWidth: 'wrap', font: 'arial',
// fontSize: 10,
// cellPadding: 8, overflowColumns: 'linebreak'
//},
});
doc.save("table.pdf");
}
</script>
Aug 27th, 2019, 11:41 PM
#4
Thread Starter
Junior Member
Re: set null in empty cell in jspdf autotable
here is td in html code where nbsp exist
Code:
<td class="blank" style="width:4rem;padding:0rem!important;text-align: center;border:0px;color: black;max-width:4rem;">
</td>
Aug 28th, 2019, 07:41 AM
#5
Thread Starter
Junior Member
Re: set null in empty cell in jspdf autotable
let me repharse same problem
, for example i have table which have three row have two columns name ,id
third row has empty cell i.e name column ,I want this kind of scenario while using jspdfautotable , that means cell should be empty/null while printing on pdf
id Name
=========================================
1 Erum
2 xyz
3
i want to do it in pdf printing ,that means when pdf generates
in which handler should i write ,below is not working
createdCell: function(cell, data) {
if (!cell.raw) {
cell.text = ' ';
}
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width