我已经测试了我的代码,它可以在 Chrome 和 Firefox 上运行,但不能在 IE 版本 9 和 10 中呈现。
我尝试过使用hack.js和compatibility.js,但它仍然不起作用。
有任何想法吗?
这是我的代码:
1.html
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="depend/compatibility.js" type="text/javascript"></script>
<script src="depend/jquery-1.9.1.js" type="text/javascript" charset="utf-8"></script>
<script src="depend/jquery-ui.js" type="text/javascript" charset="utf-8"></script>
<script src="depend/spin.js" type="text/javascript" charset="utf-8"></script>
<script src="depend/jquery.spin.js" type="text/javascript" charset="utf-8"></script>
<script src="depend/pdf.js" type="text/javascript" charset="utf-8"></script>
<script src="depend/hack.js" type="text/javascript"></script>
<script src="depend/l10n.js" type="text/javascript"></script>
<script src="depend/debugger.js" type="text/javascript"></script>
<canvas id="canvas" style="width:100%;height:100%"></canvas>
2.js
PDFJS.getDocument("hello.pdf").then(function getPdfHelloWorld(pdf) {
pdf.getPage(3).then(function getPageHelloWorld(page) {
var scale = 1.5;
var viewport = page.getViewport(scale);
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
canvas.height = viewport.height;
canvas.width = viewport.width;
page.render({
canvasContext : context,
viewport : viewport
});
});
});