我已经测试了我的代码,它适用于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
});
});
});