Personalized Prenatal Nutrition Plan

Personalized Prenatal Nutrition Plan

Tell Us About Yourself

Dietary Preferences

Health Considerations

Your Sample Daily Meal Plan

Generate a plan from the 'Your Details' tab to see your results here.

Key Nutrients for Your Trimester

Generate a plan to see your key nutrient guide.

Download Your Nutrition Plan

Generate a comprehensive PDF of your personalized meal plan and nutritional guidance. This can be useful for grocery shopping and meal prep.

Preferences: ${preferences.length > 0 ? preferences.join(', ').replace(/_/g, ' ') : 'None'}

Considerations: ${health.length > 0 ? health.join(', ').replace(/_/g, ' ') : 'None'}

`; document.getElementById('pdf-meal-plan').innerHTML = document.getElementById('meal-plan-content').innerHTML; document.getElementById('pdf-nutrients').innerHTML = document.getElementById('nutrients-content').innerHTML; // Generate PDF const { jsPDF } = window.jspdf; const originalButtonText = downloadPdfBtn.textContent; downloadPdfBtn.textContent = 'Generating...'; downloadPdfBtn.disabled = true; const content = document.getElementById('pdf-content'); const clone = content.cloneNode(true); clone.style.position = 'absolute'; clone.style.left = '-9999px'; clone.style.top = '0'; clone.style.display = 'block'; document.body.appendChild(clone); try { const canvas = await html2canvas(clone, { scale: 2, useCORS: true, logging: false }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'portrait', unit: 'px', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const imgWidth = canvas.width; const imgHeight = canvas.height; const ratio = imgWidth / imgHeight; let finalImgWidth = pdfWidth; let finalImgHeight = pdfWidth / ratio; if (finalImgHeight > pdfHeight) { finalImgHeight = pdfHeight; finalImgWidth = pdfHeight * ratio; } pdf.addImage(imgData, 'PNG', 0, 0, finalImgWidth, finalImgHeight); pdf.save('Prenatal-Nutrition-Plan.pdf'); } catch (error) { console.error("PDF Generation Error:", error); } finally { document.body.removeChild(clone); downloadPdfBtn.textContent = 'Download PDF Report'; downloadPdfBtn.disabled = false; } } // --- Event Listeners --- generatePlanBtn.addEventListener('click', generatePlan); downloadPdfBtn.addEventListener('click', generatePDF); // --- Initial Call --- showTab(0); });
Scroll to Top