Nostalgia Story Creator

Nostalgia Story Creator

Weave a short story from the fragments of yesteryear.

${story}

`; // Wrap in paragraph outputContainer.classList.remove('hidden'); outputContainer.scrollIntoView({ behavior: 'smooth' }); } function downloadPDF() { if (!currentStory) { console.error("No story to download."); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF(); const era = eraEl.value; // --- PDF Template: A Page from a Vintage Book --- const page_width = doc.internal.pageSize.getWidth(); const margin = 20; let current_y = 30; // 1. Title doc.setFont("times", "bold"); doc.setFontSize(22); doc.setTextColor(61, 43, 31); // Dark Brown doc.text("A Story From The Past", page_width / 2, current_y, { align: "center" }); current_y += 10; // 2. Sub-header with Era doc.setFont("times", "italic"); doc.setFontSize(12); doc.setTextColor(122, 82, 88); // Muted Brown doc.text(`(Circa ${era})`, page_width / 2, current_y, { align: "center" }); current_y += 20; // 3. Story Body doc.setFont("times", "normal"); doc.setFontSize(13); doc.setTextColor(45, 30, 20); // Very Dark Brown const splitText = doc.splitTextToSize(currentStory, page_width - (margin * 2)); // Add indentation to the first line const firstLine = " " + splitText.shift(); splitText.unshift(firstLine); doc.text(splitText, margin, current_y, { lineHeightFactor: 1.5 }); // 4. Footer const page_height = doc.internal.pageSize.getHeight(); doc.setLineWidth(0.2); doc.setDrawColor(220, 208, 192); // Faded Sepia line doc.line(margin, page_height - 18, page_width - margin, page_height - 18); doc.setFont("times", "italic"); doc.setFontSize(9); doc.setTextColor(100, 116, 139); // Slate 500 const date = new Date().toLocaleDateString('en-US'); doc.text(`Recalled on: ${date}`, margin, page_height - 10); doc.text("Nostalgia Story Creator", page_width - margin, page_height - 10, { align: "right" }); // Save PDF const filename = `Nostalgia_Story.pdf`; doc.save(filename); } });
Scroll to Top