Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #32845

pdf.js TextLayerBuilder (was: pdf.js textlayerbuilder)

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject pdf.js TextLayerBuilder (was: pdf.js textlayerbuilder)
Date 2017-03-25 10:45 +0100
Organization PointedEars Software (PES)
Message-ID <1924053.NgBsaNRSFp@PointedEars.de> (permalink)
References <sOednVm8kM_3VEnFnZ2dnUU7-cfNnZ2d@westnet.com.au>

Show all headers | View raw


Andrew Poulos wrote:

> I've been playing with pdf.js and I'm trying to get text selection to
> work. In the file text_layer_builder.js there's this
> 
> var TextLayerBuilder = (function TextLayerBuilderClosure() {
>    function TextLayerBuilder(options) {
>      this.textLayerDiv = options.textLayerDiv;
>      ...
>    }
>    ...
>    return TextLayerBuilder;
> })();
> 
> What I don't understand is why when I add
>    console.log(typeof TextLayerBuilder);
> it returns "undefined".

     [That is _not_ a question.]

As you could have guessed, it is a *local* (module-private) variable.
The indentation is deceiving:

,----[<https://github.com/mozilla/pdf.js/blob/master/web/text_layer_builder.js>:18]
|
| (function (root, factory) {
|   […]
| }(this, function (exports, domEvents, pdfjsLib) {
                                                  ^
| […]
| /**
|  * TextLayerBuilder provides text-selection functionality for the PDF.
|  * It does this by creating overlay divs over the PDF text. These divs
|  * contain text that matches the PDF text they are overlaying. This object
|  * also provides a way to highlight text that is being searched for.
|  * @class
|  */
| var TextLayerBuilder = (function TextLayerBuilderClosure() {
|   […]
| })();
| 
| […]
| }));
  ^
`----

I recommend that you use an editor like Atom where matching braces can be 
highlighted/jumped to, and sections can be collapsed.

In order to avoid confusion, I prefix module-private variables with “_”;
it would have been “_TextLayerBuilder”.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

pdf.js textlayerbuilder Andrew Poulos <ap_prog@hotmail.com> - 2017-03-24 18:23 +1100
  pdf.js TextLayerBuilder (was: pdf.js textlayerbuilder) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-03-25 10:45 +0100

csiph-web