eBookReaderSwitch/mupdf/platform/wasm/view-as-svg.html

45 lines
1.2 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Loading...</title>
<meta charset="utf-8">
<style>
html,body,table,tr,td,div{background-color:gray;margin:0;padding:0;}
ul{margin:0;padding-left:1em;}
#outline{background-color:silver;padding:1em;padding-left:2em;}
#pages{margin:0em;width:100%;}
.page>svg{margin:1em 1em;background-color:white;}
</style>
<script src="libmupdf.js"></script>
<script>
var filename = new URL(window.location.href).searchParams.get("file");
if (!filename)
filename = "pdfref13.pdf";
Module.preRun = function () {
FS.createPreloadedFile(".", filename, filename, true, false);
};
Module.postRun = function () {
var currentDocument = null;
var pageCount = 0;
var currentPage = 1;
function loadNextPage() {
var element = document.createElement('div');
element.id = 'page' + currentPage;
element.className = 'page';
element.innerHTML = mupdf.drawPageAsSVG(currentDocument, currentPage);
document.getElementById("pages").appendChild(element);
if (++currentPage <= pageCount)
setTimeout(loadNextPage, 0);
}
currentDocument = mupdf.openDocument(filename);
document.title = mupdf.documentTitle(currentDocument);
pageCount = mupdf.countPages(currentDocument);
loadNextPage();
}
</script>
</head>
<body>
<div id="pages"></div>
</body>
</html>