mirror of
https://github.com/kbenestad/reimburse.git
synced 2026-06-18 08:04:31 +00:00
Place PDF logo at absolute 10mm from top-left, above all content
Logo is now pinned to an absolute position (10mm from top, 10mm from left) independent of the content cursor, so it can never overlap any form elements. The cursor y is pushed below the logo bottom before the title and remaining header elements are drawn. https://claude.ai/code/session_016aNBqHpiQciTr1DvNvE7nk
This commit is contained in:
parent
9749b70fe2
commit
66396219af
1 changed files with 9 additions and 5 deletions
|
|
@ -564,20 +564,24 @@ async function generatePDF() {
|
||||||
addPage(true);
|
addPage(true);
|
||||||
|
|
||||||
// Logo + title
|
// Logo + title
|
||||||
let headerBlockH = szLg;
|
const mm10 = 10 * 2.83465; // 10 mm in points
|
||||||
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, width: lw, height: lhh });
|
// Absolute position: 10 mm from top-left, above all other content
|
||||||
headerBlockH = Math.max(lhh, szLg);
|
const logoTop = pageH - mm10;
|
||||||
|
pg.drawImage(logoImage, { x: mm10, y: logoTop - lhh, width: lw, height: lhh });
|
||||||
|
// Push cursor below logo with a small gap before remaining header elements
|
||||||
|
y = Math.min(y, logoTop - lhh - 8);
|
||||||
} 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 });
|
||||||
|
y -= szLg + 8;
|
||||||
}
|
}
|
||||||
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: y - szLg, size: szLg, font: fontBold, color: accent });
|
pg.drawText(titleStr, { x: M.left + W - tw, y, size: szLg, font: fontBold, color: accent });
|
||||||
y -= headerBlockH + 8;
|
y -= szLg + 8;
|
||||||
|
|
||||||
// Intro text
|
// Intro text
|
||||||
if (CFG.intro) {
|
if (CFG.intro) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue