src/UI/page.js
function scalePage(pageNumber, viewport, context) {
  let page = document.getElementById(`pageContainer${pageNumber}`);
  let canvas = page.querySelector('.canvasWrapper canvas');
  let svg = page.querySelector('.annotationLayer');
  let wrapper = page.querySelector('.canvasWrapper');
  let textLayer = page.querySelector('.textLayer');
  let outputScale = getOutputScale(context);
  let transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  let sfx = approximateFraction(outputScale.sx);
  let sfy = approximateFraction(outputScale.sy);

  // Adjust width/height for scale
  page.style.visibility = '';
  canvas.width = roundToDivide(viewport.width * outputScale.sx, sfx[0]);
  canvas.height = roundToDivide(viewport.height * outputScale.sy, sfy[0]);
  canvas.style.width = roundToDivide(viewport.width, sfx[1]) + 'px';
  canvas.style.height = roundToDivide(viewport.height, sfx[1]) + 'px';
  svg.setAttribute('width', viewport.width);
  svg.setAttribute('height', viewport.height);
  svg.style.width = `${viewport.width}px`;
  svg.style.height = `${viewport.height}px`;
  page.style.width = `${viewport.width}px`;
  page.style.height = `${viewport.height}px`;
  wrapper.style.width = `${viewport.width}px`;
  wrapper.style.height = `${viewport.height}px`;
  textLayer.style.width = `${viewport.width}px`;
  textLayer.style.height = `${viewport.height}px`;

  return transform;
}
function scalePage(pageNumber, viewport, context) {
  let page = document.getElementById(`pageContainer${pageNumber}`);
  let canvas = page.querySelector('.canvasWrapper canvas');
  let svg = page.querySelector('.annotationLayer');
  let wrapper = page.querySelector('.canvasWrapper');
  let textLayer = page.querySelector('.textLayer');
  let outputScale = getOutputScale(context);
  let transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  let sfx = approximateFraction(outputScale.sx);
  let sfy = approximateFraction(outputScale.sy);

  // Adjust width/height for scale
  page.style.visibility = '';
  canvas.width = roundToDivide(viewport.width * outputScale.sx, sfx[0]);
  canvas.height = roundToDivide(viewport.height * outputScale.sy, sfy[0]);
  canvas.style.width = roundToDivide(viewport.width, sfx[1]) + 'px';
  canvas.style.height = roundToDivide(viewport.height, sfx[1]) + 'px';
  svg.setAttribute('width', viewport.width);
  svg.setAttribute('height', viewport.height);
  svg.style.width = `${viewport.width}px`;
  svg.style.height = `${viewport.height}px`;
  page.style.width = `${viewport.width}px`;
  page.style.height = `${viewport.height}px`;
  wrapper.style.width = `${viewport.width}px`;
  wrapper.style.height = `${viewport.height}px`;
  textLayer.style.width = `${viewport.width}px`;
  textLayer.style.height = `${viewport.height}px`;

  return transform;
}
function scalePage ( pageNumber , viewport , context ) { let page = document . getElementById ( ` ${ pageNumber } ` ) ; let canvas = page . querySelector ( '.canvasWrapper canvas' ) ; let svg = page . querySelector ( '.annotationLayer' ) ; let wrapper = page . querySelector ( '.canvasWrapper' ) ; let textLayer = page . querySelector ( '.textLayer' ) ; let outputScale = getOutputScale ( context ) ; let transform = ! outputScale . scaled ? null : [ outputScale . sx , 0 , 0 , outputScale . sy , 0 , 0 ] ; let sfx = approximateFraction ( outputScale . sx ) ; let sfy = approximateFraction ( outputScale . sy ) ; // Adjust width/height for scale page . style . visibility = '' ; canvas . width = roundToDivide ( viewport . width * outputScale . sx , sfx [ 0 ] ) ; canvas . height = roundToDivide ( viewport . height * outputScale . sy , sfy [ 0 ] ) ; canvas . style . width = roundToDivide ( viewport . width , sfx [ 1 ] ) + 'px' ; canvas . style . height = roundToDivide ( viewport . height , sfx [ 1 ] ) + 'px' ; svg . setAttribute ( 'width' , viewport . width ) ; svg . setAttribute ( 'height' , viewport . height ) ; svg . style . width = ` ${ viewport . width } ` ; svg . style . height = ` ${ viewport . height } ` ; page . style . width = ` ${ viewport . width } ` ; page . style . height = ` ${ viewport . height } ` ; wrapper . style . width = ` ${ viewport . width } ` ; wrapper . style . height = ` ${ viewport . height } ` ; textLayer . style . width = ` ${ viewport . width } ` ; textLayer . style . height = ` ${ viewport . height } ` ; return transform ; }
Scale the elements of a page.

@param {Number} pageNumber The page number to be scaled
@param {Object} viewport The viewport of the PDF page (see pdfPage.getViewport(scale, rotate))
@param {Object} context The canvas context that the PDF page is rendered to
@return {Array} The transform data for rendering the PDF page
Scale the elements of a page .