BMI to Body Fat Percentage Estimator
Estimated Body Fat Percentage
BMI: ${bmi.toFixed(1)}
Estimated Body Fat %: ${bodyFat.toFixed(1)}%
`; resultDiv.style.display = "block"; }; window.downloadBodyFatPDF = function () { const bmi = parseFloat(document.getElementById("bmiValue").value); const gender = document.getElementById("gender").value; if (isNaN(bmi) || bmi <= 0 || !gender) { alert("Please provide valid BMI and gender before downloading."); return; } const bodyFat = gender === "male" ? (1.20 * bmi) + (0.23 * 30) - 16.2 : (1.20 * bmi) + (0.23 * 30) - 5.4; const { jsPDF } = window.jspdf; const doc = new jsPDF(); doc.setFont("helvetica", "bold"); doc.setFontSize(16); doc.text("BMI to Body Fat Percentage Estimator", 20, 20); doc.setFont("helvetica", "normal"); doc.setFontSize(12); doc.text(`BMI: ${bmi.toFixed(1)}`, 20, 40); doc.text(`Gender: ${gender.charAt(0).toUpperCase() + gender.slice(1)}`, 20, 50); doc.text(`Estimated Body Fat Percentage: ${bodyFat.toFixed(1)}%`, 20, 60); doc.save("BMI_to_Body_Fat_Percentage.pdf"); }; });