怎么启动html页面,HTML网页怎样在浏览器打开?

回答: Previous Next Page:NOTE:Modifying the URL below to another server will likely *NOT* work.

回答:

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);

});

发布者:admin,转转请注明出处:http://www.yc00.com/web/1737921428a3997524.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信