I am facing an issue with displaying a PDF using the PDFJS library on my page. The fixed scale that I have set is causing the canvas, where the PDF is rendered, to not be responsive and fit within the bootstrap grid column width. Below is the HTML code snippet:
<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>
Here is the TypeScript code snippet used in the controller:
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
};
//...further actions
});
}
If anyone has any suggestions or hints on how to resolve this issue, it would be highly appreciated.