Skip to content

Commit

Permalink
Fixes Downloaded Timetable
Browse files Browse the repository at this point in the history
Set bg-color to blue for the table to reflect in jsPDF
Pass page size properly to jsPDF to print entire page

Unrelated: also improve timetable generation by passing time to clean
only if time exists.

Fixes #13
  • Loading branch information
RachitKeertiDas committed Jan 6, 2023
1 parent 71007a5 commit d9a2fab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/timetable/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
color: white;
font-size: 1.2rem;
border-collapse: collapse;
background-color: #1f2739;
}
td {
border: 0.3px solid gray;
Expand Down
9 changes: 7 additions & 2 deletions src/timetable/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ while (true) {
.getElementsByTagName('span')[1]
.textContent.split('-')[2]
}`;
time = clean(time);
time = time ? clean(time) : time;
let possibilities = slotIndex[day]?.[time];
for (let i = 1; i < currentTimetableRows.length; i += 1) {
const day2 = currentTimetableRows[i]
Expand Down Expand Up @@ -289,7 +289,12 @@ document.addEventListener('DOMContentLoaded', () => {
.getElementsByClassName('download-pdf')[0]
.addEventListener('click', () => {
const element = document.getElementById('timetable');
html2pdf(element);
const opt = {
filename: 'timetable.pdf',
pagebreak: 'avoid-all',
jsPDF: { unit:'px', orientation:'landscape', format:[1470,415] }
};
const worker = html2pdf().set(opt).from(element).save();
});
});

Expand Down

0 comments on commit d9a2fab

Please sign in to comment.