\n";
html += "";generatedHTML = html;preview.innerHTML = generatedHTML;downloadBtn.disabled = false;convertBtn.disabled = false;showStatus(
"PDF converted to HTML successfully!"
);} catch (error) {console.error(error);showStatus(
"Unable to convert this PDF. Please try another PDF."
);convertBtn.disabled = false;}});// Download HTMLdownloadBtn.addEventListener("click", function () {if (!generatedHTML) {showStatus(
"Please convert the PDF first."
);return;
}const blob = new Blob(
[generatedHTML],
{
type: "text/html;charset=utf-8"
}
);const url =
URL.createObjectURL(blob);const a =
document.createElement("a");let name =
selectedFile
? selectedFile.name.replace(/\.pdf$/i, "")
: "converted";a.href = url;a.download =
name + ".html";document.body.appendChild(a);a.click();document.body.removeChild(a);URL.revokeObjectURL(url);showStatus(
"HTML file downloaded successfully!"
);});// ClearclearBtn.addEventListener("click", function () {selectedFile = null;generatedHTML = "";fileInput.value = "";fileName.textContent = "";preview.innerHTML =
"Your converted HTML will appear here.";convertBtn.disabled = true;downloadBtn.disabled = true;showStatus("");});// Escape HTMLfunction escapeHTML(text) {return text
.replace(/&/g, "&")
.replace(//g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");}// Statusfunction showStatus(message) {status.textContent = message;}