Pet Adoption Bio Writer
Fill in the details below to generate a heartwarming adoption bio.
Your Generated Bio
A little about ${possessivePronoun} past: ${background}
`; } // Special needs or quirks if (specialNeeds) { bio += `Please note, ${name} has a few special considerations. ${capitalizedPronoun} ${specialNeeds.startsWith('requires') || specialNeeds.startsWith('is') ? '' : 'is '}${specialNeeds}. We're happy to discuss these with any potential adopter.
`; } // Closing statement bio += `If you're looking for a devoted friend to join your family, ${name} might just be the one for you. Don't wait – come and meet this amazing ${species.toLowerCase()} today!
`; if (bioContentForPDF && outputContainer) { bioContentForPDF.innerHTML = bio; outputContainer.classList.remove('hidden'); // Scroll to the result outputContainer.scrollIntoView({ behavior: 'smooth' }); } } function downloadPDF() { // Null check elements required for PDF generation if (!petNameEl || !speciesEl || !breedEl || !ageEl || !genderEl || !sizeEl || !backgroundEl || !specialNeedsEl || !personalityTraitsEl || !bioContentForPDF) { console.error("Could not find necessary elements to generate the PDF."); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF(); // --- Get all data from the form --- const name = petNameEl.value.trim() || 'Unnamed Pet'; const species = speciesEl.value; const breed = breedEl.value.trim(); const age = ageEl.value; const gender = genderEl.value; const size = sizeEl.value; const background = backgroundEl.value.trim(); const specialNeeds = specialNeedsEl.value.trim(); const selectedTraits = Array.from(personalityTraitsEl.querySelectorAll('input[name="personality"]:checked')) .map(cb => cb.value); // --- PDF Styling and Layout --- const page_width = doc.internal.pageSize.getWidth(); const margin = 15; let current_y = 20; // --- 1. PDF Header --- doc.setFont("helvetica", "bold"); doc.setFontSize(22); doc.setTextColor(44, 62, 80); // Dark Blue-Gray doc.text("Pet Adoption Profile", page_width / 2, current_y, { align: "center" }); current_y += 15; doc.setLineWidth(0.5); doc.line(margin, current_y, page_width - margin, current_y); current_y += 15; // --- 2. Pet's Name --- doc.setFontSize(26); doc.setTextColor(39, 174, 96); // Green doc.text(name, margin, current_y); current_y += 10; // --- 3. Basic Details Section --- doc.setFont("helvetica", "normal"); doc.setFontSize(12); doc.setTextColor(52, 73, 94); // Normal Text Color let basicDetails = `Species: ${species} | Breed: ${breed || 'N/A'} | Age: ${age || 'N/A'} years | Gender: ${gender} | Size: ${size}`; doc.text(basicDetails, margin, current_y); current_y += 15; // --- Utility function to draw a section with wrapped text --- const drawSection = (title, content) => { if (!content || content.length === 0) return; // Don't draw empty sections doc.setFont("helvetica", "bold"); doc.setFontSize(14); doc.setTextColor(44, 62, 80); doc.text(title, margin, current_y); doc.setLineWidth(0.2); doc.line(margin, current_y + 2, margin + 20, current_y + 2); // Underline effect current_y += 10; doc.setFont("helvetica", "normal"); doc.setFontSize(12); doc.setTextColor(52, 73, 94); // This handles text wrapping automatically const splitText = doc.splitTextToSize(content, page_width - (margin * 2)); doc.text(splitText, margin, current_y); current_y += (splitText.length * 7) + 10; // Move Y down based on number of lines }; // --- 4. Personality Section --- if (selectedTraits.length > 0) { drawSection("Personality & Traits", selectedTraits.join(', ')); } // --- 5. Background / History Section --- drawSection("Background & History", background); // --- 6. Special Considerations Section --- drawSection("Special Needs & Quirks", specialNeeds); // --- 7. Generated Bio Section --- // We use the generated bio from the web view for consistency const webBioText = bioContentForPDF.innerText; drawSection("Adoption Bio", webBioText.replace(/(\r\n|\n|\r)/gm, " ").replace(/Meet .*!/, "")); // --- 8. Footer --- const page_height = doc.internal.pageSize.getHeight(); doc.setLineWidth(0.5); doc.line(margin, page_height - 18, page_width - margin, page_height - 18); doc.setFont("helvetica", "italic"); doc.setFontSize(8); doc.setTextColor(127, 140, 141); // Gray doc.text(`Generated on: ${new Date().toLocaleDateString('en-US')}`, margin, page_height - 10); doc.text("Pet Adoption Bio Writer", page_width - margin, page_height - 10, { align: "right" }); // --- Save the PDF --- const filename = `${name.replace(/ /g, '_')}_Adoption_Profile.pdf`; doc.save(filename); } });