admin 管理员组文章数量: 1086019
回答:
Previous
Next
Page: /
//
// NOTE:
// Modifying the URL below to another server will likely *NOT* work. BecAuse of browser
// security restrictions, we have to use a file server with special headers
// (CORS) - most servers don't SUpport cross-origin browser requests.
//
var url = 'http://cdn.mozilla/PDFjs/tracemonkey.PDF';
//
// Disable workers to avoID yet another cross-origin isSUe (workers need the URL of
// the script to be loaded, and currently do not allow cross-origin scripts)
//
PDFJS.disableWorker = true;
var PDFDoc = null,
pageNum = 1,
scale = 0.8,
canvas = document.getElementById('the-canvas'),
ctx = canvas.getContext('2d');
//
// Get page info from document, resize canvas aCCordingly, and render page
//
function renderPage(num) {
// Using PRomise to fetch the page
PDFDoc.getPage(num).then(function(page) {
var viewport = page.getViewport(scale);
canvas.height = viewport.height;
canvas.wIDth = viewport.wIDth;
// Render PDF page into canvas context
var renderContext = {
canvasContext: ctx,
viewport: viewport
};
page.render(renderContext);
});
// Update page counters
document.getElementById('page_num').textContent = pageNum;
document.getElementById('page_count').textContent = PDFDoc.numPages;
}
//
// Go to PRevious page
//
function goPrevious() {
if (pageNum <= 1)
return;
pageNum--;
renderPage(pageNum);
}
//
// Go to next page
//
function goNext() {
if (pageNum >= PDFDoc.numPages)
return;
pageNum++;
renderPage(pageNum);
}
//
// Asynchronously download PDF as an ArrayBuffer
//
PDFJS.getDocument(url).then(function getPdfHelloWorld(_PDFDoc) {
PDFDoc = _PDFDoc;
renderPage(pageNum);
});
版权声明:本文标题:怎么启动html页面,HTML网页怎样在浏览器打开? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/b/1737921432a1896563.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论