${content}`); win.document.close(); setTimeout(() => { win.print(); win.close(); }, 500); } function downloadPNG() { const el = $('#calendar-container'); const canvas = document.createElement('canvas'); const w = 700, h = 600; canvas.width = w * 2; canvas.height = h * 2; const ctx = canvas.getContext('2d'); ctx.scale(2, 2); ctx.fillStyle = '#fff'; ctx.fillRect(0, 0, w, h); const months = t('monthNames'); const year = curDate.getFullYear(); const month = curDate.getMonth(); ctx.fillStyle = headerColor; ctx.font = 'bold 28px system-ui'; ctx.textAlign = 'center'; ctx.fillText(`${months[month]} ${year}`, w / 2, 50); const days = weekStart === 'monday' ? t('dayNamesMon') : t('dayNames'); ctx.fillStyle = headerColor; ctx.font = 'bold 12px system-ui'; const cellW = (w - 60) / 7; days.forEach((d, i) => { ctx.fillText(d, 30 + cellW * i + cellW / 2, 90); }); ctx.strokeStyle = '#f0f0f0'; ctx.beginPath(); ctx.moveTo(30, 98); ctx.lineTo(w - 30, 98); ctx.stroke(); const firstDay = new Date(year, month, 1).getDay(); const daysInMonth = new Date(year, month + 1, 0).getDate(); const daysInPrev = new Date(year, month, 0).getDate(); let offset = weekStart === 'monday' ? (firstDay + 6) % 7 : firstDay; let day = 1; let nextDay = 1; const today = new Date(); ctx.font = '14px system-ui'; ctx.textAlign = 'center'; for (let row = 0; row < 6; row++) { for (let col = 0; col < 7; col++) { const cellIdx = row * 7 + col; let d; if (cellIdx < offset) { d = daysInPrev - offset + cellIdx + 1; ctx.fillStyle = '#ccc'; } else if (day > daysInMonth) { d = nextDay++; ctx.fillStyle = '#ccc'; } else { d = day++; const isToday = d === today.getDate() && month === today.getMonth() && year === today.getFullYear(); if (isToday) { ctx.fillStyle = headerColor; ctx.beginPath(); ctx.roundRect(30 + col * cellW + 10, 106 + row * 68, cellW - 20, 56, 6); ctx.fill(); ctx.fillStyle = '#fff'; } else { ctx.fillStyle = '#333'; } } ctx.fillText(d, 30 + col * cellW + cellW / 2, 140 + row * 68); } } canvas.toBlob(blob => { const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = `calendar-${year}-${month + 1}.png`; a.click(); URL.revokeObjectURL(url); }); } render(); GZ.renderToolPage({ category: 'calc', titleKey: 'toolTitle', descKey: 'toolDesc', howToSteps: ['step1','step2','step3','step4'], related: [ {icon:'📅', href:'/calc/date-calculator.html', name:'Date Calculator'}, {icon:'⏱️', href:'/calc/countdown-timer.html', name:'Countdown Timer'}, {icon:'⏰', href:'/calc/countdown-timer.html', name:'Countdown Timer'}, ] });