2022-08-07 01:20:50 +00:00
|
|
|
<!DOCTYPE html><html>
|
|
|
|
<title>docx2html</title>
|
|
|
|
<head>
|
2022-08-11 08:10:44 +00:00
|
|
|
<script src="https://fastly.jsdelivr.net/npm/mammoth@1.4.8/mammoth.browser.min.js"></script>
|
2022-08-07 01:20:50 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div>
|
|
|
|
<center>
|
|
|
|
<h2>select a docx to convert to html</h2>
|
|
|
|
<input type="file" onchange="convert(this)"/>
|
|
|
|
</center>
|
2022-08-11 08:10:44 +00:00
|
|
|
<div id="container"></div>
|
2022-08-07 01:20:50 +00:00
|
|
|
</div>
|
2022-08-11 08:10:44 +00:00
|
|
|
<script>
|
|
|
|
var container = document.querySelector("#container");
|
|
|
|
function convert(input){
|
|
|
|
var files = input.files||[];
|
|
|
|
if (!files.length) return;
|
|
|
|
var file = files[0];
|
|
|
|
var reader = new FileReader();
|
|
|
|
reader.onloadend = function(event) {
|
|
|
|
var arrayBuffer = reader.result;
|
|
|
|
mammoth.convertToHtml({arrayBuffer: arrayBuffer}).then(function (resultObject) {
|
|
|
|
container.innerHTML = resultObject.value
|
|
|
|
});
|
|
|
|
}
|
|
|
|
reader.readAsArrayBuffer(file);
|
|
|
|
}
|
|
|
|
</script>
|
2022-08-07 01:20:50 +00:00
|
|
|
</body>
|
|
|
|
</html>
|