mirror of
https://github.com/kbenestad/reimburse.git
synced 2026-06-18 08:04:31 +00:00
Fix PDF logo overlapping form fields
The logo was placed with a fixed +10pt offset that didn't account for actual logo height. Content below always advanced by a fixed 28pt, so any logo taller than ~18pt bled into the intro text and form fields. Now the logo is anchored with its top at the cursor position (bottom at y - lhh), the title baseline aligns to the same top edge, and y advances by max(logoHeight, titleSize) + 8pt gap before the next element. https://claude.ai/code/session_016aNBqHpiQciTr1DvNvE7nk
This commit is contained in:
parent
f72607fa9e
commit
9749b70fe2
1 changed files with 5 additions and 3 deletions
|
|
@ -564,18 +564,20 @@ async function generatePDF() {
|
||||||
addPage(true);
|
addPage(true);
|
||||||
|
|
||||||
// Logo + title
|
// Logo + title
|
||||||
|
let headerBlockH = szLg;
|
||||||
if (logoImage) {
|
if (logoImage) {
|
||||||
const maxW = (CFG['logo-maxwidth'] || 4) * 28.3465;
|
const maxW = (CFG['logo-maxwidth'] || 4) * 28.3465;
|
||||||
const scale = Math.min(maxW / logoImage.width, 50 / logoImage.height, 1);
|
const scale = Math.min(maxW / logoImage.width, 50 / logoImage.height, 1);
|
||||||
const lw = logoImage.width * scale, lhh = logoImage.height * scale;
|
const lw = logoImage.width * scale, lhh = logoImage.height * scale;
|
||||||
pg.drawImage(logoImage, { x: M.left, y: y - lhh + 10, width: lw, height: lhh });
|
pg.drawImage(logoImage, { x: M.left, y: y - lhh, width: lw, height: lhh });
|
||||||
|
headerBlockH = Math.max(lhh, szLg);
|
||||||
} else if (CFG.organization) {
|
} else if (CFG.organization) {
|
||||||
pg.drawText(CFG.organization, { x: M.left, y, size: szLg, font: fontBold, color: accent });
|
pg.drawText(CFG.organization, { x: M.left, y, size: szLg, font: fontBold, color: accent });
|
||||||
}
|
}
|
||||||
const titleStr = 'REIMBURSEMENT FORM';
|
const titleStr = 'REIMBURSEMENT FORM';
|
||||||
const tw = fontBold.widthOfTextAtSize(titleStr, szLg);
|
const tw = fontBold.widthOfTextAtSize(titleStr, szLg);
|
||||||
pg.drawText(titleStr, { x: M.left + W - tw, y, size: szLg, font: fontBold, color: accent });
|
pg.drawText(titleStr, { x: M.left + W - tw, y: y - szLg, size: szLg, font: fontBold, color: accent });
|
||||||
y -= 28;
|
y -= headerBlockH + 8;
|
||||||
|
|
||||||
// Intro text
|
// Intro text
|
||||||
if (CFG.intro) {
|
if (CFG.intro) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue