Online Synonym & Antonym Finder

Online Synonym & Antonym Finder

No antonyms found.

`; if (antonyms && antonyms.length > 0) { antonymsHtml = `
    ${createListHtml(antonyms)}
`; } return `

Thesaurus Report

For the word: ${word}

Generated on: ${date}

Synonyms

${synonymsHtml}

Antonyms

${antonymsHtml}
`; }; // --- PDF Generation Function --- const generatePdf = () => { if (!searchResults) { alert("Please find synonyms/antonyms for a word first."); return; } const { jsPDF } = window.jspdf; const originalButtonText = downloadPdfBtn.innerHTML; downloadPdfBtn.innerHTML = 'Generating PDF...'; downloadPdfBtn.disabled = true; pdfRenderContainer.innerHTML = buildPdfReportHtml(searchResults); html2canvas(pdfRenderContainer, { scale: 2, useCORS: true }) .then(canvas => { const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'portrait', unit: 'px', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const imgProps = pdf.getImageProperties(imgData); const imgAspectRatio = imgProps.width / imgProps.height; let finalWidth, finalHeight; if (pdfWidth / pdfHeight > imgAspectRatio) { finalHeight = pdfHeight; finalWidth = finalHeight * imgAspectRatio; } else { finalWidth = pdfWidth; finalHeight = finalWidth / imgAspectRatio; } pdf.addImage(imgData, 'PNG', 0, 0, finalWidth, finalHeight); pdf.save(`Thesaurus_Report_${searchResults.word}.pdf`); }) .catch(err => { console.error("Error generating PDF:", err); alert("Sorry, there was an error creating the PDF."); }) .finally(() => { downloadPdfBtn.innerHTML = originalButtonText; downloadPdfBtn.disabled = false; pdfRenderContainer.innerHTML = ''; }); }; // --- Event Listeners --- findBtn.addEventListener('click', findAndDisplay); wordInput.addEventListener('keyup', (event) => { if (event.key === 'Enter') { findAndDisplay(); } }); synonymsTabBtn.addEventListener('click', () => switchToTab('synonyms')); antonymsTabBtn.addEventListener('click', () => switchToTab('antonyms')); downloadPdfBtn.addEventListener('click', generatePdf); });
Scroll to Top