fix: dynamic PDF height based on receipt content length
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -273,6 +273,10 @@ export async function downloadReceiptPDF(txnNumber?: string) {
|
||||
const el = document.getElementById('pos-receipt-print')
|
||||
if (!el) return
|
||||
|
||||
// Calculate height from actual content
|
||||
const heightPx = el.scrollHeight + 16 // 16px padding
|
||||
const heightMm = Math.ceil(heightPx * 0.265) + 8 // px to mm + margin
|
||||
|
||||
const html2pdf = (await import('html2pdf.js')).default
|
||||
html2pdf()
|
||||
.set({
|
||||
@@ -280,7 +284,7 @@ export async function downloadReceiptPDF(txnNumber?: string) {
|
||||
filename: `receipt-${txnNumber ?? 'unknown'}.pdf`,
|
||||
image: { type: 'jpeg', quality: 0.95 },
|
||||
html2canvas: { scale: 2, useCORS: true, width: 280 },
|
||||
jsPDF: { unit: 'mm', format: [72, 250], orientation: 'portrait' },
|
||||
jsPDF: { unit: 'mm', format: [72, heightMm], orientation: 'portrait' },
|
||||
})
|
||||
.from(el)
|
||||
.save()
|
||||
|
||||
Reference in New Issue
Block a user