diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2018-09-10 18:18:49 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2018-10-23 17:23:59 +0200 |
commit | 8ebce9c149112d59552ed530361f80372455fdb2 (patch) | |
tree | ebc90eb93345d1b3a77841ed2a92e56a4c1b1baf /platform/wasm/view-as-html.html | |
parent | ddd00f62888c908c84932c2a92a0c2d195b26c36 (diff) | |
download | mupdf-8ebce9c149112d59552ed530361f80372455fdb2.tar.xz |
Add Emscripten / WebAssembly build.
Requires Linux (or possibly MacOS X) and an installed emsdk to build.
Diffstat (limited to 'platform/wasm/view-as-html.html')
-rw-r--r-- | platform/wasm/view-as-html.html | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/platform/wasm/view-as-html.html b/platform/wasm/view-as-html.html new file mode 100644 index 00000000..d31d23a2 --- /dev/null +++ b/platform/wasm/view-as-html.html @@ -0,0 +1,45 @@ +<!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>div{margin:1em auto;} +</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.drawPageAsHTML(currentDocument, currentPage); + element.getElementsByTagName("div")[0].style.backgroundImage = 'url(' + mupdf.drawPage(currentDocument, currentPage, 96) + ')' + 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> |