Kuvert: Absender oben links, Empfaenger unten rechts sauber positioniert

Positionierung ueber Hoehen-/Breiten-Anteile statt ueber den grossen Kuvert-Rand
(marginTop bis ~50% der Hoehe): Absender ~14% oben/6% links, Empfaenger ~65-80%
unten/rechts. Vorher klebten beide im mittleren Band.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
s4luorth
2026-09-01 15:30:40 +02:00
parent 42a0d2d8b1
commit e3764b70bd

View File

@@ -297,7 +297,7 @@ function generateEnvelopeSVG(text, format, type, options = {}) {
// type === 'recipient' / 'free'. Ist ein Absender gesetzt, sitzt der // type === 'recipient' / 'free'. Ist ein Absender gesetzt, sitzt der
// Empfänger UNTEN RECHTS (klassisches Kuvert), sonst wie bisher oben links. // Empfänger UNTEN RECHTS (klassisches Kuvert), sonst wie bisher oben links.
const hatAbsender = !!String(options.sender || '').trim(); const hatAbsender = !!String(options.sender || '').trim();
const maxWidthPx = Math.min(widthPx - marginLeftPx - 20, widthPx * (hatAbsender ? 0.48 : 0.6)); const maxWidthPx = Math.min(widthPx - marginLeftPx - 20, widthPx * (hatAbsender ? 0.44 : 0.6));
lines = wrapTextToLinesByWidth({ lines = wrapTextToLinesByWidth({
text: String(text || ''), text: String(text || ''),
@@ -307,8 +307,11 @@ function generateEnvelopeSVG(text, format, type, options = {}) {
}); });
if (hatAbsender) { if (hatAbsender) {
startX = Math.max(marginLeftPx, Math.round(widthPx * 0.48)); // Empfänger unten rechts – bewusst über Höhen-/Breiten-Anteile, damit der
startY = Math.max(marginTopPx + fontSizePx, heightPx - marginTopPx - lines.length * lineHeightPx + fontSizePx); // große Kuvert-Rand (marginTop bis ~50 % der Höhe) nicht alles nach oben zieht.
startX = Math.round(widthPx * 0.52);
const untenBaseline = heightPx * 0.80; // unterste Zeile ~20 % über der Unterkante
startY = Math.round(untenBaseline - Math.max(0, lines.length - 1) * lineHeightPx);
} else { } else {
startX = marginLeftPx; startX = marginLeftPx;
startY = marginTopPx + fontSizePx; startY = marginTopPx + fontSizePx;
@@ -364,8 +367,9 @@ function generateEnvelopeSVG(text, format, type, options = {}) {
lines: absLines, lines: absLines,
fontFileName: fontConfig.file, fontFileName: fontConfig.file,
fontSizePx: absSize, fontSizePx: absSize,
startX: marginLeftPx, // Echt oben links – unabhängig vom großen Kuvert-Rand.
startY: marginTopPx + absSize, startX: Math.round(widthPx * 0.06),
startY: Math.round(heightPx * 0.14),
lineHeightPx: absLH, lineHeightPx: absLH,
realisticHandwriting: options.realisticHandwriting ?? false, realisticHandwriting: options.realisticHandwriting ?? false,
}); });