概述
回答:
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.net/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);
});
最后
以上就是甜甜烧鹅为你收集整理的浏览器自动调html5,HTML5是如何使用的?打开网页时自动启动吗?浏览器自带?还是需要安装什么插件?...的全部内容,希望文章能够帮你解决浏览器自动调html5,HTML5是如何使用的?打开网页时自动启动吗?浏览器自带?还是需要安装什么插件?...所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复