Home Workout & Minimal Equipment Training Guide

Home Workout & Minimal Equipment Training Guide

A 4-day weekly plan focusing on full-body fitness.

Sets: ${ex.sets} | Reps: ${ex.reps}

${ex.desc}

`).join(''); workoutPlanContent.innerHTML = `

${workout.title}

${workout.focus}

${exercisesHtml}
`; } // --- PDF GENERATION --- window.downloadPDF = async () => { const { jsPDF } = window.jspdf; const reportContainer = document.createElement('div'); reportContainer.id = 'pdf-report'; reportContainer.className = 'w-[800px] bg-white p-10 text-gray-800'; reportContainer.style.position = 'absolute'; reportContainer.style.left = '-9999px'; reportContainer.style.fontFamily = 'Inter, sans-serif'; const allWorkoutsHtml = Object.values(state.workouts).map(workout => { const exercisesHtml = workout.exercises.map(ex => ` ${ex.name} ${ex.sets} ${ex.reps} ${ex.desc} `).join(''); return `

${workout.title}

${workout.focus}

${exercisesHtml}
ExerciseSetsReps/DurationDescription
`; }).join(''); reportContainer.innerHTML = `

Home Workout Plan

Generated: ${new Date().toLocaleString('en-US', { dateStyle: 'full', timeStyle: 'short' })}

${allWorkoutsHtml}

This plan provides general recommendations. Listen to your body and rest when needed. Consult a professional for personalized fitness advice, especially if you have pre-existing health conditions.

`; document.body.appendChild(reportContainer); try { const canvas = await html2canvas(reportContainer, { scale: 2, useCORS: true, logging: false }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'portrait', unit: 'mm', format: 'a4' }); const pageHeight = pdf.internal.pageSize.getHeight(); const pageWidth = pdf.internal.pageSize.getWidth(); const margin = 15; const contentWidth = pageWidth - (margin * 2); const imgProps = pdf.getImageProperties(imgData); const contentHeight = (imgProps.height * contentWidth) / imgProps.width; let heightLeft = contentHeight; let position = 0; pdf.addImage(imgData, 'PNG', margin, margin, contentWidth, contentHeight); heightLeft -= (pageHeight - (margin * 2)); while (heightLeft > 0) { position -= (pageHeight - (margin * 2)); pdf.addPage(); pdf.addImage(imgData, 'PNG', margin, position + margin, contentWidth, contentHeight); heightLeft -= (pageHeight - (margin * 2)); } pdf.save('Home-Workout-Plan.pdf'); } catch (error) { console.error("Error generating PDF:", error); alert("Sorry, there was an error creating the PDF report."); } finally { document.body.removeChild(reportContainer); } }; // --- INITIALIZATION --- switchTab(1); });
Scroll to Top