Online Text Shortener

Online Text Shortener

Summarize your text instantly to the desired length.

Copied to clipboard!

${textToDownload.replace(/\n/g, '
')}

`; pdfContent.style.display = 'block'; const canvas = await html2canvas(pdfContent, { scale: 2 }); pdfContent.style.display = 'none'; pdfContent.innerHTML = ''; const { jsPDF } = window.jspdf; const pdf = new jsPDF({ orientation: 'portrait', unit: 'mm', format: 'a4' }); const imgData = canvas.toDataURL('image/png'); const pdfWidth = pdf.internal.pageSize.getWidth() - 20; // with margin const pdfHeight = (canvas.height * pdfWidth) / canvas.width; pdf.addImage(imgData, 'PNG', 10, 10, pdfWidth, pdfHeight); pdf.save('shortened-text.pdf'); } catch (error) { console.error('Error generating PDF:', error); alert('Sorry, an error occurred while creating the PDF.'); } finally { pdfBtn.textContent = 'Download as PDF'; pdfBtn.disabled = false; } }; // C. Event Handling shortenBtn.addEventListener('click', handleShorten); copyBtn.addEventListener('click', handleCopyToClipboard); clearBtn.addEventListener('click', handleClear); pdfBtn.addEventListener('click', handlePdfDownload); lengthSlider.addEventListener('input', (e) => { sliderValue.textContent = `${e.target.value}%`; }); });
Scroll to Top