Add Datum und anpassung der positzionierung
This commit is contained in:
50
js/master.js
50
js/master.js
@@ -818,34 +818,32 @@ async function addSignatureToPdf() {
|
||||
const sigWidth = overlayWidth * scaleX;
|
||||
const sigHeight = sigWidth * (signatureImage.height / signatureImage.width);
|
||||
|
||||
// Convert position to PDF coordinates (bottom-left origin)
|
||||
// Convert overlay position to PDF coordinates (bottom-left origin)
|
||||
const x = overlayLeft * scaleX;
|
||||
const y = height - (overlayTop * scaleY) - sigHeight;
|
||||
const overlayTopInPdf = height - (overlayTop * scaleY);
|
||||
|
||||
// Calculate text dimensions if text exists
|
||||
let textHeight = 0;
|
||||
let textSpacing = 0;
|
||||
if (textOverlayText) {
|
||||
textHeight = textFontSize * scaleY;
|
||||
textSpacing = 5 * scaleY; // 5px spacing between text and signature
|
||||
}
|
||||
|
||||
// Position signature lower to make room for text above
|
||||
// Signature y position: overlay top - text height - spacing - signature height
|
||||
const y = overlayTopInPdf - textHeight - textSpacing - sigHeight;
|
||||
|
||||
console.log('PDF Position:', x, y, 'Größe:', sigWidth, 'x', sigHeight);
|
||||
console.log('Text Höhe:', textHeight, 'Abstand:', textSpacing);
|
||||
|
||||
// Add signature to page
|
||||
page.drawImage(signatureImage, {
|
||||
x: x,
|
||||
y: y,
|
||||
width: sigWidth,
|
||||
height: sigHeight,
|
||||
});
|
||||
|
||||
console.log('✓ Unterschrift zu Seite', pageNum, 'hinzugefügt');
|
||||
|
||||
// Add text overlay if it exists (text is part of signature overlay, positioned top-left)
|
||||
// Add text FIRST (if exists) - positioned at top of overlay
|
||||
if (textOverlayText) {
|
||||
// Text is positioned relative to signature overlay (top-left)
|
||||
// Calculate text position: overlay left position + small offset, overlay top position - small offset
|
||||
const textOffsetX = 5 * scaleX; // 5px offset from left
|
||||
const textOffsetY = -5 * scaleY; // 5px offset from top (negative because PDF y is bottom-up)
|
||||
const textX = x + textOffsetX;
|
||||
// overlayTop is from top of canvas, convert to PDF coordinates (bottom-up)
|
||||
const overlayTopInPdf = height - (overlayTop * scaleY);
|
||||
const textY = overlayTopInPdf + textOffsetY; // Top of overlay - small offset
|
||||
const textY = overlayTopInPdf - textHeight; // At top of overlay
|
||||
|
||||
// Add text to page
|
||||
// Add text to page FIRST (drawn first = appears behind signature)
|
||||
page.drawText(textOverlayText, {
|
||||
x: textX,
|
||||
y: textY,
|
||||
@@ -853,8 +851,18 @@ async function addSignatureToPdf() {
|
||||
color: rgb(0, 0, 0),
|
||||
});
|
||||
|
||||
console.log('✓ Text zu Seite', pageNum, 'hinzugefügt');
|
||||
console.log('✓ Text zu Seite', pageNum, 'hinzugefügt (oberhalb der Unterschrift)');
|
||||
}
|
||||
|
||||
// Add signature to page AFTER text (positioned lower to make room for text)
|
||||
page.drawImage(signatureImage, {
|
||||
x: x,
|
||||
y: y,
|
||||
width: sigWidth,
|
||||
height: sigHeight,
|
||||
});
|
||||
|
||||
console.log('✓ Unterschrift zu Seite', pageNum, 'hinzugefügt (unterhalb des Textes)');
|
||||
}
|
||||
|
||||
// Save PDF
|
||||
|
||||
Reference in New Issue
Block a user