Description:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Text to PDF Converter</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
text-align: center;
margin: 50px;
}
#converter {
max-width: 600px;
margin: auto;
background-color: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
textarea {
width: 100%;
height: 150px;
margin-bottom: 15px;
padding: 10px;
box-sizing: border-box;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
background-color: #4caf50;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:active {
background-color: #45a049;
}
#pdf-container {
display: none;
margin-top: 20px;
}
</style>
</head>
<body>
<div id="converter">
<h2>Text to PDF Converter</h2>
<textarea id="text-input" placeholder="Enter your text here..."></textarea>
<button onclick="convertToPDF()">Convert to PDF</button>
<div id="pdf-container">
<h3>Your PDF is ready:</h3>
<embed id="pdf-viewer" type="application/pdf" width="100%" height="500px">
<br>
<button onclick="downloadPDF()">Download PDF</button>
</div>
</div>
<script>
function convertToPDF() {
var text = document.getElementById('text-input').value;
// Use a library like html2pdf.js for converting HTML to PDF
html2pdf().from(text).outputPdf('datauristring').then(function(pdfDataUri) {
document.getElementById('pdf-viewer').src = pdfDataUri;
document.getElementById('pdf-container').style.display = 'block';
});
}
function downloadPDF() {
var pdfViewer = document.getElementById('pdf-viewer');
var pdfDataUri = pdfViewer.src;
// Trigger download
var link = document.createElement('a');
link.href = pdfDataUri;
link.download = 'converted_document.pdf';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
</script>
<!-- Include the html2pdf.js library -->
<script src="https://rawgit.com/eKoopmans/html2pdf/master/dist/html2pdf.bundle.js"></script>
</body>
</html>
PDFGenius is an intuitive Text to PDF Converter that effortlessly transforms your text into beautifully formatted PDF documents. With a sleek interface and easy-to-use features, generate professional PDFs instantly. Enhance your document creation process with PDFGenius—your go-to tool for seamless conversion and convenient downloads.
html

No comments:
Post a Comment