1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| <!-- # -*- coding: utf-8 -*- -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PDF Viewer</title>
</head>
<body>
<div id="btDiv"></div>
<div id="pdfDiv"></div>
<script>
function buildPdfViewer()
{
const iframe = document.createElement('iframe');
iframe.style.width = '650px';
iframe.style.height = '900px';
pdfDiv.innerHTML = '';
pdfDiv.appendChild(iframe);
return iframe;
}
function displayPdf(fname)
{
pdfViewer.src = fname;
}
function createButton(function_name, param1, param2, label)
{
var button = document.createElement("button");
button.textContent = label;
button.addEventListener("click", function() {function_name(param1, param2);});
btDiv.appendChild(button);
}
function goToNextPage()
{
console.log("go to next page");
// pdfViewer.somethingLikeGoToNextPage();
}
function goToPreviousPage()
{
console.log("go to previous page");
// pdfViewer.somethingLikeGoToPreviousPage();
}
var pdfDiv = document.getElementById('pdfDiv');
var btContainer = document.getElementById('btDiv');
var pdfViewer = buildPdfViewer();
displayPdf('../../home/jazz/score/book_DO.pdf')
createButton(displayPdf, '../../home/jazz/score/book_DO.pdf', null, 'book_DO');
createButton(displayPdf, '../../home/jazz/score/book_SIb.pdf', null, 'book_SIb');
createButton(displayPdf, '../../home/jazz/score/book_MIb.pdf', null, 'book_MIb');
createButton(goToNextPage, null, null, 'Next Page');
createButton(goToPreviousPage, null, null, 'Previous Page');
</script>
</body>
</html> |
Partager