Build the text layer geometry on the worker.

This commit is contained in:
Brendan Dahl 2014-04-09 16:44:07 -07:00
parent af536353d5
commit 5bd8a83c9b
10 changed files with 404 additions and 416 deletions

View file

@ -485,8 +485,8 @@ var PageView = function pageView(container, id, scale,
if (!PDFJS.disableTextLayer) {
textLayerDiv = document.createElement('div');
textLayerDiv.className = 'textLayer';
textLayerDiv.style.width = canvas.width + 'px';
textLayerDiv.style.height = canvas.height + 'px';
textLayerDiv.style.width = canvas.style.width;
textLayerDiv.style.height = canvas.style.height;
div.appendChild(textLayerDiv);
}
var textLayer = this.textLayer =
@ -503,14 +503,6 @@ var PageView = function pageView(container, id, scale,
if (outputScale.scaled) {
ctx.scale(outputScale.sx, outputScale.sy);
}
if (outputScale.scaled && textLayerDiv) {
var cssScale = 'scale(' + (1 / outputScale.sx) + ', ' +
(1 / outputScale.sy) + ')';
CustomStyle.setProp('transform' , textLayerDiv, cssScale);
CustomStyle.setProp('transformOrigin' , textLayerDiv, '0% 0%');
textLayerDiv.dataset._scaleX = outputScale.sx;
textLayerDiv.dataset._scaleY = outputScale.sy;
}
// Rendering area
@ -600,20 +592,19 @@ var PageView = function pageView(container, id, scale,
this.renderTask.promise.then(
function pdfPageRenderCallback() {
pageViewDrawCallback(null);
if (textLayer) {
self.getTextContent().then(
function textContentResolved(textContent) {
textLayer.setTextContent(textContent);
}
);
}
},
function pdfPageRenderError(error) {
pageViewDrawCallback(error);
}
);
if (textLayer) {
this.getTextContent().then(
function textContentResolved(textContent) {
textLayer.setTextContent(textContent);
}
);
}
setupAnnotations(div, pdfPage, this.viewport);
div.setAttribute('data-loaded', true);
};