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


Groups > comp.lang.javascript > #32842 > unrolled thread

pdf.js textlayerbuilder

Started byAndrew Poulos <ap_prog@hotmail.com>
First post2017-03-24 18:23 +1100
Last post2017-03-25 10:45 +0100
Articles 2 — 2 participants

Back to article view | Back to comp.lang.javascript


Contents

  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

#32842 — pdf.js textlayerbuilder

FromAndrew Poulos <ap_prog@hotmail.com>
Date2017-03-24 18:23 +1100
Subjectpdf.js textlayerbuilder
Message-ID<sOednVm8kM_3VEnFnZ2dnUU7-cfNnZ2d@westnet.com.au>
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".

Andrew Poulos

[toc] | [next] | [standalone]


#32845 — pdf.js TextLayerBuilder (was: pdf.js textlayerbuilder)

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2017-03-25 10:45 +0100
Subjectpdf.js TextLayerBuilder (was: pdf.js textlayerbuilder)
Message-ID<1924053.NgBsaNRSFp@PointedEars.de>
In reply to#32842
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.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web