我的 pdfjs 脚本有问题。
我第一次尝试,收到以下消息:
已弃用的 API 用法:未指定“GlobalWorkerOptions.workerSrc”。未捕获的异常:未定义
所以我遵循github上的文档:https://github.com/mozilla/pdf.js/issues/10478
现在我收到此消息:SyntaxError:await仅在异步函数和异步生成器中有效
<div class="d-flex justify-content-center">
<canvas id="pdf-render">
</canvas>
</div>
<div class="pdfcontroller d-flex justify-content-around">
<button class="btn btn-primary" id="prev-page">
prev page
</button>
<p class="page-info"> 1 / 2</p>
<button class="btn btn-primary" id="next-page">
Next page
</button>
</div>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.4.456/pdf.min.js">
</script>
<script>
const url = 'filesample.pdf'
let pdfDoc = null;
pageNum = 1;
pageIsrendreing = false;
pageNumisPending = null;
const scale = 1.5,
canvas = document.querySelector('#pdf-render'),
ctx = canvas.getContext('2d');
// Render the page
const renderPage = num …Run Code Online (Sandbox Code Playgroud)