Superhero/Villain Catchphrase Generator

Generated Catchphrase:

Click "Generate Catchphrase" to forge a powerful phrase!

${catchphrase.trim()}

`; } function downloadPdf() { const { jsPDF } = window.jspdf; const doc = new jsPDF({ orientation: 'P', // Portrait unit: 'mm', format: 'a4' }); // Target the output section for PDF const element = document.getElementById('phraseOutput'); // Apply temporary print styles for PDF generation (cleaner output) const pdfStyles = ` #catchphraseGenerator { background-color: #ffffff !important; /* White background for print */ color: #000 !important; /* Black text */ box-shadow: none !important; border: none !important; padding: 10mm !important; /* Use mm for consistency */ margin: 0 !important; font-size: 12pt !important; /* Readable font size */ line-height: 1.5 !important; text-transform: none !important; /* Don't force uppercase */ font-family: sans-serif !important; /* Use standard font */ } #catchphraseGenerator h2, #catchphraseGenerator h3 { color: #000 !important; /* Black headings */ text-shadow: none !important; font-family: sans-serif !important; text-transform: none !important; } #catchphraseGenerator h3 { border-bottom-color: #ccc !important; } #catchphraseGenerator .controls-section { display: none !important; /* Hide controls */ } #catchphraseGenerator .output-section { border: none !important; background-color: #fff !important; padding: 0 !important; } #catchphraseGenerator #outputContent { color: #000 !important; min-height: auto !important; text-align: left !important; /* Don't center in print */ font-size: 12pt !important; /* Readable size */ display: block !important; /* Don't use flexbox */ word-break: normal !important; padding: 0 !important; } #catchphraseGenerator #outputContent p { margin: 0 !important; padding: 0 !important; } `; const styleTag = document.createElement('style'); styleTag.setAttribute('id', 'pdfPrintStyles'); styleTag.innerHTML = pdfStyles; document.head.appendChild(styleTag); // Use html2canvas to render the element as an image/canvas html2canvas(element, { scale: 2, // Increase scale for better resolution in PDF logging: false, // Disable html2canvas logging backgroundColor: '#ffffff' // Explicitly set white background }).then(canvas => { const imgData = canvas.toDataURL('image/png'); const pdfWidth = doc.internal.pageSize.getWidth(); const pdfHeight = doc.internal.pageSize.getHeight(); const imgWidth = pdfWidth - 20; // Leave 10mm margin on each side const imgHeight = canvas.height * imgWidth / canvas.width; let heightLeft = imgHeight; let position = 10; // Starting Y position (10mm margin) // Add the image to the PDF const imgX = (pdfWidth - imgWidth) / 2; // Center the image doc.addImage(imgData, 'PNG', imgX, position, imgWidth, imgHeight); heightLeft -= (pdfHeight - position); // Handle multiple pages if content exceeds one page (unlikely) while (heightLeft >= 0) { position = 10; // Reset position for new page doc.addPage(); // Add background to the new page doc.setFillColor(255); // White doc.rect(0, 0, pdfWidth, pdfHeight, 'F'); // Calculate the source y position on the canvas image const srcY = imgHeight - heightLeft; // Add the remaining part of the image doc.addImage(imgData, 'PNG', imgX, position, imgWidth, heightLeft, null, null, 0, srcY); heightLeft -= (pdfHeight - position); } // Remove the temporary print styles const addedStyleTag = document.getElementById('pdfPrintStyles'); if (addedStyleTag) { addedStyleTag.remove(); } doc.save('superhero_catchphrase.pdf'); }).catch(error => { console.error("Error generating PDF:", error); alert("Could not generate PDF. Please try again."); // Ensure styles are removed even on error const addedStyleTag = document.getElementById('pdfPrintStyles'); if (addedStyleTag) { addedStyleTag.remove(); } }); } // Event Listeners generateBtn.addEventListener('click', generateCatchphrase); downloadPdfBtn.addEventListener('click', downloadPdf); // Initial text outputContent.innerHTML = '

Click "Generate Catchphrase" to forge a powerful phrase!

'; });

Key Features of the Light Theme

  1. Light and Clean Design: The tool uses a white background with blue accents for a modern and professional look.

  2. Centered Layout: The tool is perfectly centered on the page.

  3. Responsive Design: Works seamlessly on all devices (desktop, tablet, mobile).

  4. PDF Download: Users can download the catchphrase as a PDF with the same color scheme.

    Benefits of the Light Theme

      1. Modern Aesthetic: The light theme provides a clean and professional look, making it suitable for a wide range of websites.

      2. Readability: The high contrast between text and background ensures excellent readability.

      3. User-Friendly: The intuitive design makes it easy for users to interact with the tool.

Scroll to Top