Path: csiph.com!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: pdf.js TextLayerBuilder (was: pdf.js textlayerbuilder) Date: Sat, 25 Mar 2017 10:45:22 +0100 Organization: PointedEars Software (PES) Lines: 57 Message-ID: <1924053.NgBsaNRSFp@PointedEars.de> References: Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1490435122 18854 eJwFwYENwDAIA7CXRhtCOAel4v8TZudl0AUmkZtL872dNqQtl5CI8agVBx9n+8LWqeUb4gckJhEe (25 Mar 2017 09:45:22 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Sat, 25 Mar 2017 09:45:22 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwFwQkBwDAIA0BLsCY8cigU/xJ2x2Nq7TAauNxs751XmYq+s8VgGz1DMKGFN6VfyA2VdyGCPXmcnfE+JH5pyhVG X-NNTP-Posting-Host: eJwFwYkBwEAEBMCWsN5yiNN/CZkxOPsX6uZqZ0caFDwnrAjk0N1zrYcoaU6Z3OqgswXWX/8C7hCm Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg== Cancel-Lock: sha1:HuOnYOXIOigjf1S1Ri8XsjxiL7I= X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. 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: ,----[: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: | | Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.