body { font-family: Arial, sans-serif; margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; min-height: 100vh; background: linear-gradient(to bottom right, #4facfe, #00f2fe); color: #333; } .container { background: white; padding: 20px; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); text-align: center; max-width: 400px; width: 90%; } h1 { color: #007bff; } textarea { width: 100%; margin: 10px 0; padding: 10px; border: 2px solid #007bff; border-radius: 5px; font-size: 16px; resize: none; } button { background: #007bff; color: white; padding: 10px 15px; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; transition: background 0.3s ease; } button:hover { background: #0056b3; } .download-instructions { margin-top: 10px; font-size: 14px; color: #555; } @media (max-width: 500px) { h1 { font-size: 20px; } button { font-size: 14px; } textarea { font-size: 14px; } } document.getElementById("convertBtn").addEventListener("click", () => { const text = document.getElementById("textInput").value; if (text.trim() === "") { alert("Please enter some text to convert to PDF."); return; } // Create a new PDF document const doc = new jsPDF(); // Add the text to the PDF const pageHeight = doc.internal.pageSize.height; let y = 10; // Vertical position of text const lines = doc.splitTextToSize(text, 180); lines.forEach((line, index) => { if (y > pageHeight - 10) { doc.addPage(); // Add a new page if content overflows y = 10; } doc.text(line, 10, y); y += 10; // Line spacing }); // Download the PDF doc.save("ConvertedText.pdf"); });