From: Adil Allawi Date: Sun, 12 Feb 2012 22:31:30 +0000 (+0000) Subject: Scale text divs instead of letterspacing X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=ffa0e082a4338d3cb92bf70935dfae7d68e586e1;p=pdf.js.git Scale text divs instead of letterspacing --- diff --git a/web/viewer.js b/web/viewer.js index d5162a1..9cf97a7 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -1041,12 +1041,11 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv) { textLayerDiv.appendChild(textDiv); if (textDiv.dataset.textLength > 1) { // avoid div by zero - // Adjust div width (via letterSpacing) to match canvas text + // Adjust div width to match canvas text // Due to the .offsetWidth calls, this is slow // This needs to come after appending to the DOM - textDiv.style.letterSpacing = - ((textDiv.dataset.canvasWidth - textDiv.offsetWidth) / - (textDiv.dataset.textLength - 1)) + 'px'; + textDiv.style.MozTransform = 'scale(' + textDiv.dataset.canvasWidth/textDiv.offsetWidth + ',1)'; + textDiv.style.MozTransformOrigin = '0% 0%'; } } // textLength > 0 }