Text to PDF Converter free



Text to PDF Converter

Text to PDF Converter

body { font-family: Arial, sans-serif; background-color: #f0f0f0; margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; height: 100vh; } .container { text-align: center; background-color: #fff; padding: 20px; border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); max-width: 600px; width: 100%; } h1 { color: #007bff; } .text-input { width: 100%; height: 200px; padding: 10px; margin: 10px 0; border: 1px solid #ccc; border-radius: 5px; resize: none; } .btn { background-color: #007bff; color: #fff; border: none; padding: 10px 20px; margin: 5px; border-radius: 5px; cursor: pointer; } .btn:disabled { background-color: #ccc; cursor: not-allowed; } const inputText = document.getElementById("inputText"); const convertButton = document.getElementById("convertButton"); const downloadLink = document.getElementById("downloadLink"); convertButton.addEventListener("click", () => { const text = inputText.value; if (text.trim() !== "") { // Create a new PDF document const doc = new jsPDF(); // Add text to the PDF doc.text(text, 10, 10); // Save the PDF as a blob const pdfBlob = doc.output("blob"); // Create a download link for the PDF const pdfUrl = URL.createObjectURL(pdfBlob); downloadLink.href = pdfUrl; downloadLink.style.display = "block"; // Trigger the download downloadLink.click(); } else { alert("Please enter some text before converting to PDF."); } });