diff --git a/examples/text-selection/js/minimal.js b/examples/text-selection/js/minimal.js index b25bf4fc6..2faf33793 100644 --- a/examples/text-selection/js/minimal.js +++ b/examples/text-selection/js/minimal.js @@ -14,8 +14,13 @@ // you actually end up selecting. window.onload = function () { + if (typeof PDFJS === 'undefined') { + alert('Built version of pdf.js is not found\nPlease run `node make generic`'); + return; + } + var scale = 1.5; //Set this to whatever you want. This is basically the "zoom" factor for the PDF. - PDFJS.workerSrc = '../../src/worker_loader.js'; + PDFJS.workerSrc = '../../build/generic/build/pdf.worker.js'; function loadPdf(pdfPath) { var pdf = PDFJS.getDocument(pdfPath); @@ -33,38 +38,30 @@ window.onload = function () { // Set the canvas height and width to the height and width of the viewport var canvas = $canvas.get(0); var context = canvas.getContext("2d"); - canvas.height = viewport.height; - canvas.width = viewport.width; + + // The following few lines of code set up scaling on the context if we are on a HiDPI display + var outputScale = getOutputScale(context); + canvas.width = (Math.floor(viewport.width) * outputScale.sx) | 0; + canvas.height = (Math.floor(viewport.height) * outputScale.sy) | 0; + canvas.style.width = Math.floor(viewport.width) + 'px'; + canvas.style.height = Math.floor(viewport.height) + 'px'; // Append the canvas to the pdf container div var $pdfContainer = jQuery("#pdfContainer"); - $pdfContainer.css("height", canvas.height + "px").css("width", canvas.width + "px"); + $pdfContainer.css("height", canvas.style.height) + .css("width", canvas.style.width); $pdfContainer.append($canvas); var canvasOffset = $canvas.offset(); var $textLayerDiv = jQuery("
") .addClass("textLayer") - .css("height", viewport.height + "px") - .css("width", viewport.width + "px") + .css("height", canvas.style.height) + .css("width", canvas.style.width) .offset({ top: canvasOffset.top, left: canvasOffset.left }); - // The following few lines of code set up scaling on the context if we are on a HiDPI display - var outputScale = getOutputScale(context); - if (outputScale.scaled) { - var cssScale = 'scale(' + (1 / outputScale.sx) + ', ' + - (1 / outputScale.sy) + ')'; - CustomStyle.setProp('transform', canvas, cssScale); - CustomStyle.setProp('transformOrigin', canvas, '0% 0%'); - - if ($textLayerDiv.get(0)) { - CustomStyle.setProp('transform', $textLayerDiv.get(0), cssScale); - CustomStyle.setProp('transformOrigin', $textLayerDiv.get(0), '0% 0%'); - } - } - context._scaleX = outputScale.sx; context._scaleY = outputScale.sy; if (outputScale.scaled) { @@ -76,14 +73,14 @@ window.onload = function () { page.getTextContent().then(function (textContent) { var textLayer = new TextLayerBuilder({ textLayerDiv: $textLayerDiv.get(0), + viewport: viewport, pageIndex: 0 }); textLayer.setTextContent(textContent); var renderContext = { canvasContext: context, - viewport: viewport, - textLayer: textLayer + viewport: viewport }; page.render(renderContext); diff --git a/src/display/api.js b/src/display/api.js index aff296f64..807cce74e 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -444,8 +444,6 @@ var PDFPageProxy = (function PDFPageProxyClosure() { * @param {Object} params A parameter object that supports: * { * canvasContext(required): A 2D context of a DOM Canvas object., - * textLayer(optional): An object that has beginLayout, endLayout, and - * appendText functions., * imageLayer(optional): An object that has beginLayout, endLayout and * appendImage functions., * continueCallback(optional): A function that will be called each time