Virtual Puppet Theater Script Generator

Generate a simple text script for a puppet show!

Your puppet show script will appear here!

Your puppet show script will appear here!

'; document.getElementById('downloadPdfBtn').style.display = 'none'; // Hide PDF button }); // Download PDF Button document.getElementById('downloadPdfBtn').addEventListener('click', () => { const resultsDiv = document.getElementById('scriptResults'); const scriptContent = resultsDiv.textContent.trim(); if (!scriptContent || scriptContent.includes('Your puppet show script will appear here!') || scriptContent.includes('Generating script...')) { alert("No script 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("Puppet Show Script", margin, y); y += 15; // Space after title doc.setFontSize(10); // Smaller font for script content doc.setTextColor(52, 58, 64); // Match text-color variable #343a0 // Extract lines from HTML and add to PDF resultsDiv.childNodes.forEach(node => { if (node.nodeType === 1) { // Element node if (node.classList.contains('action')) { // Add action lines const actionText = node.textContent.trim(); const actionLines = doc.splitTextToSize(`[${actionText}]`, maxLineWidth - 10); // Add brackets, indent actionLines.forEach(line => { if (y + 6 > pageHeight - margin) { // Estimate line height + padding doc.addPage(); y = margin; doc.setFontSize(18); doc.setTextColor(52, 58, 64); doc.text("Puppet Show Script (cont.)", margin, y); y += 15; doc.setFontSize(10); doc.setTextColor(52, 58, 64); } doc.text(line, margin + 10, y); // Indent action y += 6; // Estimate line height }); y += 5; // Space after action block } else if (node.tagName === 'P') { // Add dialogue lines const speakerElement = node.querySelector('strong'); const speaker = speakerElement ? speakerElement.textContent.trim() : 'Unknown:'; const dialogueText = node.textContent.replace(speaker, '').trim(); const speakerWidth = doc.getTextWidth(speaker); // Check if content fits on current page const textLines = doc.splitTextToSize(dialogueText, maxLineWidth - speakerWidth - 5); // Estimate wrapped text lines let estimatedHeight = Math.max(6, textLines.length * 6); // Estimate line height if (y + estimatedHeight > pageHeight - margin && y > margin) { doc.addPage(); y = margin; doc.setFontSize(18); doc.setTextColor(52, 58, 64); doc.text("Puppet Show Script (cont.)", margin, y); y += 15; doc.setFontSize(10); doc.setTextColor(52, 58, 64); } doc.text(speaker, margin, y); doc.text(textLines, margin + speakerWidth + 5, y); // Position dialogue text y += estimatedHeight + 3; // Move down for the next line, add small buffer } } }); doc.save('puppet_show_script.pdf'); });

Key Features:

  1. Customizable Inputs: Users can input characters, setting, and plot to generate unique puppet show scripts.

  2. AI-Generated Scripts: The tool creates vivid and imaginative puppet show scripts 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 puppet show script 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 engaging puppet show scripts for entertainment or personal projects.

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

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

    4. Portable Results: The PDF download feature allows users to save and share their generated scripts 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