now it"s like this, how to implement a canvas that loads pdf, and then scrolls, otherwise the browser will slide down for a long time if there are too many pdf pages
/ / programs can only run on the server
window.onload = function () {
//
function createPdfContainer(id, className) {
var pdfContainer = document.getElementById("pdf-container");
var canvasNew = document.createElement("canvas");
canvasNew.id = id;
canvasNew.className = className;
pdfContainer.appendChild(canvasNew);
};
//pdf
//pdf
function renderPDF(pdf, i, id) {
pdf.getPage(i).then(function (page) {
var scale = 1.5;
var viewport = page.getViewport(scale);
//
// canvas
//
var canvas = document.getElementById(id);
var context = canvas.getContext("2d");
canvas.height = viewport.height;
canvas.width = "825";
//
// PDF canvas
//
var renderContext = {
canvasContext: context,
viewport: viewport
};
page.render(renderContext);
});
};
//pdfcanvas
function createSeriesCanvas(num, template) {
var id = "";
for (var j = 1; j <= num; jPP) {
id = template + j;
createPdfContainer(id, "pdfClass");
}
$("-sharppdf-container").append("<a href="javaScript:closePDF()" class="closeP"></a>");
}
//pdf
function loadPDF(fileURL) {
PDFJS.getDocument(fileURL).then(function (pdf) {
// promise
var id = "";
var idTemplate = "cw-pdf-";
var pageNum = pdf.numPages;
//
createSeriesCanvas(pageNum, idTemplate);
//pdf
for (var i = 1; i <= pageNum; iPP) {
id = idTemplate + i;
renderPDF(pdf, i, id);
}
});
}
//pdf
loadPDF("@(imgUrl)Script/PDF/tzzn.pdf");
//pdf
//loadPDF("Script/PDF/tzzn.pdf");
};