Skip to content

Commit

Permalink
adding a way to allow large pdfs to zoom to the correct size (Univers…
Browse files Browse the repository at this point in the history
  • Loading branch information
404mike committed Sep 15, 2020
1 parent d3e8a14 commit 67167e4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/modules/uv-pdfcenterpanel-module/PDFCenterPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,25 @@ export class PDFCenterPanel extends CenterPanel {
this._canvas.height = this._viewport.height;
this._canvas.width = this._viewport.width;


// get divisible number between canvas height and content height
const divisible_amount = this._canvas.height / this.$content.height()
// create a variable for the new canvas height.
// (canvas height divided by our divisible_amount) multiply by the viewport scale
var canvas_height = (this._canvas.height / divisible_amount) * this._viewport.scale;

// if canvas height is smaller than our content height
// use the content hight instead
if(canvas_height < this.$content.height()) {
canvas_height = this.$content.height();
}

// set the canvas height with CSS
this._$canvas.css({
height: canvas_height
});


// Render PDF page into canvas context
const renderContext = {
canvasContext: this._ctx,
Expand Down

0 comments on commit 67167e4

Please sign in to comment.