use --scale-factor variable to set text layer font size
Newer pdf.js versions requires this variable to be set equal to the actual scale (zoom ratio), to properly set font size in text layer div.
This commit is contained in:
parent
f5a1452a2d
commit
2dea11799c
@ -12,6 +12,8 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#container {
|
#container {
|
||||||
|
--scale-factor: 1;
|
||||||
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: grid;
|
display: grid;
|
||||||
|
@ -7,6 +7,7 @@ let pageRendering = false;
|
|||||||
let renderPending = false;
|
let renderPending = false;
|
||||||
let renderPendingZoom = 0;
|
let renderPendingZoom = 0;
|
||||||
const canvas = document.getElementById('content');
|
const canvas = document.getElementById('content');
|
||||||
|
const container = document.getElementById("container");
|
||||||
let orientationDegrees = 0;
|
let orientationDegrees = 0;
|
||||||
let zoomRatio = 1;
|
let zoomRatio = 1;
|
||||||
let textLayerDiv = document.getElementById("text");
|
let textLayerDiv = document.getElementById("text");
|
||||||
@ -82,6 +83,7 @@ function renderPage(pageNumber, zoom, prerender, prerenderTrigger=0) {
|
|||||||
|
|
||||||
textLayerDiv.replaceWith(cached.textLayerDiv);
|
textLayerDiv.replaceWith(cached.textLayerDiv);
|
||||||
textLayerDiv = cached.textLayerDiv;
|
textLayerDiv = cached.textLayerDiv;
|
||||||
|
container.style.setProperty("--scale-factor", newZoomRatio.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
pageRendering = false;
|
pageRendering = false;
|
||||||
@ -153,6 +155,7 @@ function renderPage(pageNumber, zoom, prerender, prerenderTrigger=0) {
|
|||||||
if (useRender) {
|
if (useRender) {
|
||||||
textLayerDiv.replaceWith(newTextLayerDiv);
|
textLayerDiv.replaceWith(newTextLayerDiv);
|
||||||
textLayerDiv = newTextLayerDiv;
|
textLayerDiv = newTextLayerDiv;
|
||||||
|
container.style.setProperty("--scale-factor", newZoomRatio.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cache.length === maxCached) {
|
if (cache.length === maxCached) {
|
||||||
|
Loading…
Reference in New Issue
Block a user