Paranormal Story Generator

Generate a short story featuring ghosts, cryptids, or other unexplained phenomena!

Your paranormal story will appear here!

Your paranormal story will appear here!

'; document.getElementById('downloadPdfBtn').style.display = 'none'; // Hide PDF button }); // Download PDF Button document.getElementById('downloadPdfBtn').addEventListener('click', () => { const resultsDiv = document.getElementById('storyResults'); const storyText = resultsDiv.textContent.trim(); // Get text content, which preserves line breaks from


        if (!storyText || storyText.includes('Your paranormal story will appear here!') || storyText.includes('Crafting spooky tale...')) {
             alert("No story to download.");
             return;
        }

        // --- PDF Generation ---
        const doc = new jsPDF();

        const margin = 15;
        let y = margin;
        const pageHeight = doc.internal.pageSize.height;
        const pageWidth = doc.internal.pageSize.width;
        const maxLineWidth = pageWidth - 2 * margin; // Max width for text line

        doc.setFontSize(18);
        doc.setTextColor(52, 58, 64); // Match text-color variable #343a0
        doc.text("A Paranormal Story", margin, y);
        y += 15; // Space after title

        doc.setFontSize(12);
        doc.setTextColor(52, 58, 64); // Match text-color variable #343a0

         // Add the story text, handling wrapping and preserving line breaks (\n)
        const lines = storyText.split('\n'); // Split the entire text by newline characters

         lines.forEach(line => {
             // If a line is empty or just whitespace, treat it as a paragraph break
              if (line.trim() === "") {
                  y += 7; // Add extra space for paragraph break (estimate line height)
              } else {
                  const wrappedLines = doc.splitTextToSize(line, maxLineWidth);
                  wrappedLines.forEach(wrappedLine => {
                       if (y + 7 > pageHeight - margin) { // Estimate line height + padding
                           doc.addPage();
                           y = margin;
                           doc.setFontSize(18);
                           doc.setTextColor(52, 58, 64);
                           doc.text("A Paranormal Story (cont.)", margin, y);
                           y += 15;
                           doc.setFontSize(12);
                           doc.setTextColor(52, 58, 64);
                       }
                       doc.text(wrappedLine, margin, y);
                       y += 7; // Estimate line height
                  });
              }
         });


        doc.save('paranormal_story.pdf');
    });

				

Key Features:

  1. Customizable Inputs: Users can input location, character, and paranormal activity to generate unique stories.

  2. AI-Generated Stories: The tool creates engaging and spooky paranormal stories based on user inputs.

  3. Centered Design: The tool is perfectly centered on the page, ensuring a clean and professional look.

  4. PDF Download: Users can download the generated story as a PDF, complete with the same color scheme for consistency.

  5. Responsive Design: The tool is fully responsive and works seamlessly on all devices.

    Benefits for End Users:

    1. Creative Fun: Users can generate unique and spooky stories for entertainment or personal projects.

    2. Customizable Outputs: The tool allows users to tailor the generated stories based on specific traits.

    3. Educational Tool: Great for students and educators to explore creative writing and storytelling concepts.

    4. Portable Results: The PDF download feature allows users to save and share their generated stories easily.

    5. User-Friendly Interface: The simple and intuitive design ensures that users of all ages and technical skill levels can use the tool effortlessly.

Scroll to Top