我必须在我的页面上使用 PDFJS 库显示 PDF。问题是,由于我将比例设置为呈现 PDF 的固定数字画布,因此没有响应并且不适合引导网格列的宽度。这是HTML代码:
<div class="row">
<div class="col-md-1" style="padding-right: 15px;">
<input type="button" ng-click="openPreviousPage()"/>
</div>
<div class="col-md-8">
<canvas id="the-canvas" style="border: 1px solid black;"></canvas>
</div>
<div class="col-md-1 col-md-offset-2" style="padding-right:15px;">
<input type="button" ng-click="openNextPage()" />
</div>
</div>
和我在控制器中的打字稿:
openPage = (pdf: PDFDocumentProxy, pageNumber: number) => {
pdf.getPage(pageNumber).then(function getPage(page) {
var scale = 1;
var viewport = page.getViewport(scale);
var canvas = <HTMLCanvasElement>document.getElementById('the-canvas');
var context = canvas.getContext('2d');
canvas.height = viewport.height;
canvas.width = viewport.width;
var renderContext = {
canvasContext: context,
viewport: viewport
};
//...rest of actions
});
}
将不胜感激任何提示。