Download PDF
body {
text-align: center;
padding: 20px;
}
h1 {
color: #333;
}
input[type="file"] {
margin-top: 20px;
}
button {
margin-top: 10px;
}
a {
display: none;
margin-top: 10px;
color: #333;
}
// Wait for the DOM to load
document.addEventListener('DOMContentLoaded', function() {
// Get the file input and convert button elements
var pptFileInput = document.getElementById('pptFile');
var convertButton = document.getElementById('convertBtn');
var downloadLink = document.getElementById('downloadLink');
// Add event listener to the convert button
convertButton.addEventListener('click', function() {
// Check if a file is selected
if (pptFileInput.files.length > 0) {
var pptFile = pptFileInput.files[0];
// Create a new FileReader instance
var reader = new FileReader();
// Read the file as binary string
reader.readAsBinaryString(pptFile);
// Handle the file load event
reader.onload = function(e) {
// Convert the PPT to PDF using a conversion library or API
var pptData = e.target.result;
var pdfData = convertPptToPdf(pptData);
// Create a Blob object from the PDF data
var pdfBlob = new Blob([pdfData], { type: 'application/pdf' });
// Generate a temporary URL for the PDF Blob
var pdfUrl = URL.createObjectURL(pdfBlob);
// Set the download link href to the PDF URL and display it
downloadLink.href = pdfUrl;
downloadLink.style.display = 'block';
};
}
});
});
// Function to convert PPT to PDF (placeholder function)
function convertPptToPdf(pptData) {
// Replace this function with your own implementation or integrate a conversion library or API
// Return the converted PDF data
return 'Converted PDF Data';
}
Comments
Post a Comment