diff --git a/public/js/organization.js b/public/js/organization.js index 8e04982..33c2fff 100644 --- a/public/js/organization.js +++ b/public/js/organization.js @@ -33,7 +33,7 @@ var loadPDF = async function(pdfBlob, filename, pdfIndex) { let pageIndex = pdfLetter + "_" + (page.pageNumber - 1); pages[pageIndex] = page; - document.getElementById('container-pages').insertAdjacentHTML('beforeend', '

Page '+page.pageNumber+' - '+filename+'

'); + document.getElementById('container-pages').insertAdjacentHTML('beforeend', '

Page '+page.pageNumber+' - '+filename+'

'); let canvasContainer = document.getElementById('canvas-container-' + pageIndex); canvasContainer.addEventListener('dragstart', function(e) { @@ -96,9 +96,21 @@ var loadPDF = async function(pdfBlob, filename, pdfIndex) { var pageRender = function(pageIndex, rotation = 0) { let page = pages[pageIndex]; let viewport = page.getViewport({scale: 1, rotation: rotation}); - let scale = (document.getElementById('container-pages').clientWidth - (12*nbPagePerLine) - 12) / viewport.width / nbPagePerLine; - viewport = page.getViewport({scale: scale, rotation: rotation}); + let size = (document.getElementById('container-pages').offsetWidth - (12*nbPagePerLine) - 12) / nbPagePerLine; + let scaleWidth = size / viewport.width; + let scaleHeight = size / viewport.height; + let viewportWidth = page.getViewport({scale: scaleWidth, rotation: rotation}); + let viewportHeight = page.getViewport({scale: scaleHeight, rotation: rotation}); + + if(viewportWidth.height > size) { + viewport = viewportHeight; + } else { + viewport = viewportWidth; + } + let canvasContainer = document.getElementById('canvas-container-' + pageIndex); + canvasContainer.style.height = (size + 4) + "px"; + canvasContainer.style.width = (size + 4) + "px"; let canvasPDF = canvasContainer.querySelector('.canvas-pdf'); let context = canvasPDF.getContext('2d'); document.querySelector('#input_rotate_'+pageIndex).value = rotation; @@ -108,7 +120,6 @@ var pageRender = function(pageIndex, rotation = 0) { page.render({ canvasContext: context, viewport: viewport, - enhanceTextSelection: true }); } diff --git a/templates/organization.html.php b/templates/organization.html.php index 161f367..f3adb79 100644 --- a/templates/organization.html.php +++ b/templates/organization.html.php @@ -35,7 +35,7 @@
-
+