I need to rotate the text from the head array in the pdf.autotable.
When I try the following code, I get the text displayed in both vertical and horizontal direction, but I only want the vertical alignment.
This is my code:
pdf.autoTable({
head: [
[
"DATUM",
"BP KRANK",
"STUNDEN NORM",
"STUNDEN SPÄT",
"STUNDEN WE",
"STUNDEN NACHT",
"FRÜHSTÜCK",
"ZNÜNI",
"MITTAG",
"ZVIERI",
"ABENDESSEN",
"KILOMETER",
"DIVERSES",
"JG / MAG",
],
],
body,
startY: pdf.previousAutoTable.finalY + 5,
margin: {right: 5, left: 5},
theme: "grid",
styles: {halign: "center", fontSize: 8},
headStyles: {
fillColor: [211, 211, 211],
},
columnStyles: {
0: {cellWidth: 15.38, fillColor: [218, 233, 212]},
1: {cellWidth: 15.38, fillColor: [217, 225, 242]},
2: {cellWidth: 15.38},
3: {cellWidth: 15.38, fillColor: [246, 203, 204]},
4: {cellWidth: 15.38, fillColor: [243, 243, 243]},
5: {cellWidth: 15.38, fillColor: [254, 255, 153]},
6: {cellWidth: 15.38},
7: {cellWidth: 15.38},
8: {cellWidth: 15.38},
9: {cellWidth: 15.38},
10: {cellWidth: 15.38},
11: {cellWidth: 15.38},
12: {cellWidth: 15.38},
13: {cellWidth: 15.38, fillColor: [217, 225, 242]},
},
didDrawCell: function(data) {
const doc = data.doc;
if (data.section === "head") {
const text = data.cell.raw;
const x = data.cell.x + data.cell.width / 2;
const y = data.cell.y + data.cell.height / 2;
doc.setFontSize(8);
doc.text(text, x, y, null, 90);
}
},
});
How can I solve the problem.
Thx.
Sample Image
New contributor
Mario Magnus is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.