fix: non-bold table headers, nudge Year Level left, center units + total to match reference
This commit is contained in:
@@ -185,7 +185,8 @@
|
||||
if (header.program) page.drawText(compactProgram(header.program), { x: 338, y, size: 9, font, color: black });
|
||||
if (yearLevelText) {
|
||||
const w = font.widthOfTextAtSize(yearLevelText, 9);
|
||||
page.drawText(yearLevelText, { x: margin + contentWidth - w, y, size: 9, font, color: black });
|
||||
// Right-aligned to the content edge, nudged left ~12pt (~1rem).
|
||||
page.drawText(yearLevelText, { x: margin + contentWidth - w - 12, y, size: 9, font, color: black });
|
||||
}
|
||||
if (header.studentId || header.fullName || header.program || yearLevelText) y -= 14.5;
|
||||
|
||||
@@ -209,7 +210,7 @@
|
||||
const widths = {};
|
||||
for (const c of cols) {
|
||||
const key = c.label.toUpperCase().replace(/\s+/g, '_');
|
||||
widths[key] = bold.widthOfTextAtSize(c.label, headerSize);
|
||||
widths[key] = font.widthOfTextAtSize(c.label, headerSize);
|
||||
}
|
||||
return {
|
||||
GROUP: cols[0].x,
|
||||
@@ -236,7 +237,8 @@
|
||||
}
|
||||
|
||||
function drawRow(cells, isHeader) {
|
||||
const f = isHeader ? bold : font;
|
||||
// Header labels and data all use the body font (header is not bold).
|
||||
const f = font;
|
||||
const size = isHeader ? headerSize : cellSize;
|
||||
const linesPerCol = rowLines(cells);
|
||||
|
||||
@@ -288,8 +290,9 @@
|
||||
let ty = y;
|
||||
for (const line of lines) {
|
||||
if (c.key === 'units') {
|
||||
// Center unit values under the UNITS header, matching the reference.
|
||||
const w = f.widthOfTextAtSize(line, size);
|
||||
page.drawText(line, { x: c.x + c.w - w, y: ty, size, font: f, color: black });
|
||||
page.drawText(line, { x: c.x + (c.w - w) / 2, y: ty, size, font: f, color: black });
|
||||
} else if (c.key === 'status') {
|
||||
page.drawText(line, { x: c.x + 35, y: ty, size, font: f, color: black });
|
||||
} else {
|
||||
@@ -336,12 +339,12 @@
|
||||
}
|
||||
y -= 12;
|
||||
if (data.totalUnits) {
|
||||
// Total sits under the UNITS column, right-aligned within it.
|
||||
// Total sits under the UNITS column, centered within it (matches reference).
|
||||
const unitsCol = cols[4];
|
||||
const w = bold.widthOfTextAtSize(data.totalUnits, 8);
|
||||
// Short underline above the total, spanning the UNITS column.
|
||||
hline(unitsCol.x, unitsCol.x + unitsCol.w, y + 9);
|
||||
page.drawText(data.totalUnits, { x: unitsCol.x + unitsCol.w - w, y, size: 8, font: bold, color: black });
|
||||
page.drawText(data.totalUnits, { x: unitsCol.x + (unitsCol.w - w) / 2, y, size: 8, font: bold, color: black });
|
||||
y -= 12;
|
||||
}
|
||||
hline(margin, margin + contentWidth, y);
|
||||
|
||||
Reference in New Issue
Block a user