Meal Plan Generator

Input Mode

Calories = use weight & daily calories (auto-calc macros). Macros = enter protein, carbs & fats directly.

Not sure of your calories? Use our calorie calculator.

`); w.document.close(); w.focus(); w.print(); w.close(); }); // PDF via html2pdf function ensureHtml2PdfLoaded() { return new Promise((resolve) => { if (window.html2pdf) return resolve(true); const s = document.createElement('script'); s.src = 'https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js'; s.onload = () => resolve(true); document.head.appendChild(s); }); } pdfBtn?.addEventListener('click', async () => { if (!outputEl?.innerHTML.trim()) { alert('Nothing to download yet. Generate a plan first.'); return; } await ensureHtml2PdfLoaded(); const wrapper = document.createElement('div'); wrapper.style.padding = '16px'; wrapper.style.maxWidth = '720px'; wrapper.style.margin = '0 auto'; wrapper.style.color = '#000'; wrapper.style.background = '#fff'; if (LOGO_URL) { const logo = document.createElement('img'); logo.src = LOGO_URL; logo.alt = 'MJ Fitness'; logo.style.maxHeight = '40px'; logo.style.display = 'block'; logo.style.margin = '0 auto 8px'; wrapper.appendChild(logo); } const title = document.createElement('h2'); title.textContent = 'Meal Plan'; title.style.textAlign = 'center'; title.style.margin = '0 0 12px'; title.style.color = '#000'; wrapper.appendChild(title); const content = document.createElement('div'); content.innerHTML = outputEl.innerHTML; const style = document.createElement('style'); style.textContent = ` .meal-card { border:1px solid #ddd; border-radius:10px; padding:15px; margin-bottom:20px; } h3 { color:#FC0041; } ul,ol { margin-left: 18px; } `; wrapper.appendChild(style); wrapper.appendChild(content); const opt = { margin: 10, filename: 'MJ-Fitness-Meal-Plan.pdf', image: { type: 'jpeg', quality: 0.98 }, html2canvas: { scale: 2, useCORS: true }, jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' } }; window.html2pdf().set(opt).from(wrapper).save(); }); })();