pdf_viewer.js 169 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193
  1. /* Copyright 2017 Mozilla Foundation
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. (function webpackUniversalModuleDefinition(root, factory) {
  16. if(typeof exports === 'object' && typeof module === 'object')
  17. module.exports = factory();
  18. else if(typeof define === 'function' && define.amd)
  19. define("pdfjs-dist/web/pdf_viewer", [], factory);
  20. else if(typeof exports === 'object')
  21. exports["pdfjs-dist/web/pdf_viewer"] = factory();
  22. else
  23. root["pdfjs-dist/web/pdf_viewer"] = root.pdfjsDistWebPdfViewer = factory();
  24. })(this, function() {
  25. return /******/ (function(modules) { // webpackBootstrap
  26. /******/ // The module cache
  27. /******/ var installedModules = {};
  28. /******/
  29. /******/ // The require function
  30. /******/ function __w_pdfjs_require__(moduleId) {
  31. /******/
  32. /******/ // Check if module is in cache
  33. /******/ if(installedModules[moduleId]) {
  34. /******/ return installedModules[moduleId].exports;
  35. /******/ }
  36. /******/ // Create a new module (and put it into the cache)
  37. /******/ var module = installedModules[moduleId] = {
  38. /******/ i: moduleId,
  39. /******/ l: false,
  40. /******/ exports: {}
  41. /******/ };
  42. /******/
  43. /******/ // Execute the module function
  44. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  45. /******/
  46. /******/ // Flag the module as loaded
  47. /******/ module.l = true;
  48. /******/
  49. /******/ // Return the exports of the module
  50. /******/ return module.exports;
  51. /******/ }
  52. /******/
  53. /******/
  54. /******/ // expose the modules object (__webpack_modules__)
  55. /******/ __w_pdfjs_require__.m = modules;
  56. /******/
  57. /******/ // expose the module cache
  58. /******/ __w_pdfjs_require__.c = installedModules;
  59. /******/
  60. /******/ // define getter function for harmony exports
  61. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  62. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  63. /******/ Object.defineProperty(exports, name, {
  64. /******/ configurable: false,
  65. /******/ enumerable: true,
  66. /******/ get: getter
  67. /******/ });
  68. /******/ }
  69. /******/ };
  70. /******/
  71. /******/ // getDefaultExport function for compatibility with non-harmony modules
  72. /******/ __w_pdfjs_require__.n = function(module) {
  73. /******/ var getter = module && module.__esModule ?
  74. /******/ function getDefault() { return module['default']; } :
  75. /******/ function getModuleExports() { return module; };
  76. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  77. /******/ return getter;
  78. /******/ };
  79. /******/
  80. /******/ // Object.prototype.hasOwnProperty.call
  81. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  82. /******/
  83. /******/ // __webpack_public_path__
  84. /******/ __w_pdfjs_require__.p = "";
  85. /******/
  86. /******/ // Load entry module and return exports
  87. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 9);
  88. /******/ })
  89. /************************************************************************/
  90. /******/ ([
  91. /* 0 */
  92. /***/ (function(module, exports, __w_pdfjs_require__) {
  93. "use strict";
  94. var pdfjsLib = void 0;
  95. if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
  96. pdfjsLib = window['pdfjs-dist/build/pdf'];
  97. } else {
  98. pdfjsLib = require('../build/pdf.js');
  99. }
  100. module.exports = pdfjsLib;
  101. /***/ }),
  102. /* 1 */
  103. /***/ (function(module, exports, __w_pdfjs_require__) {
  104. "use strict";
  105. Object.defineProperty(exports, "__esModule", {
  106. value: true
  107. });
  108. exports.waitOnEventOrTimeout = exports.WaitOnType = exports.localized = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.mozL10n = exports.RendererType = exports.PresentationModeState = exports.cloneObj = exports.isValidRotation = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = undefined;
  109. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  110. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  111. var _pdfjsLib = __w_pdfjs_require__(0);
  112. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  113. var CSS_UNITS = 96.0 / 72.0;
  114. var DEFAULT_SCALE_VALUE = 'auto';
  115. var DEFAULT_SCALE = 1.0;
  116. var MIN_SCALE = 0.25;
  117. var MAX_SCALE = 10.0;
  118. var UNKNOWN_SCALE = 0;
  119. var MAX_AUTO_SCALE = 1.25;
  120. var SCROLLBAR_PADDING = 40;
  121. var VERTICAL_PADDING = 5;
  122. var PresentationModeState = {
  123. UNKNOWN: 0,
  124. NORMAL: 1,
  125. CHANGING: 2,
  126. FULLSCREEN: 3
  127. };
  128. var RendererType = {
  129. CANVAS: 'canvas',
  130. SVG: 'svg'
  131. };
  132. function formatL10nValue(text, args) {
  133. if (!args) {
  134. return text;
  135. }
  136. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  137. return name in args ? args[name] : '{{' + name + '}}';
  138. });
  139. }
  140. var NullL10n = {
  141. getDirection: function getDirection() {
  142. return Promise.resolve('ltr');
  143. },
  144. get: function get(property, args, fallback) {
  145. return Promise.resolve(formatL10nValue(fallback, args));
  146. },
  147. translate: function translate(element) {
  148. return Promise.resolve();
  149. }
  150. };
  151. _pdfjsLib.PDFJS.disableFullscreen = _pdfjsLib.PDFJS.disableFullscreen === undefined ? false : _pdfjsLib.PDFJS.disableFullscreen;
  152. _pdfjsLib.PDFJS.useOnlyCssZoom = _pdfjsLib.PDFJS.useOnlyCssZoom === undefined ? false : _pdfjsLib.PDFJS.useOnlyCssZoom;
  153. _pdfjsLib.PDFJS.maxCanvasPixels = _pdfjsLib.PDFJS.maxCanvasPixels === undefined ? 16777216 : _pdfjsLib.PDFJS.maxCanvasPixels;
  154. _pdfjsLib.PDFJS.disableHistory = _pdfjsLib.PDFJS.disableHistory === undefined ? false : _pdfjsLib.PDFJS.disableHistory;
  155. _pdfjsLib.PDFJS.disableTextLayer = _pdfjsLib.PDFJS.disableTextLayer === undefined ? false : _pdfjsLib.PDFJS.disableTextLayer;
  156. {
  157. _pdfjsLib.PDFJS.locale = _pdfjsLib.PDFJS.locale === undefined && typeof navigator !== 'undefined' ? navigator.language : _pdfjsLib.PDFJS.locale;
  158. }
  159. function getOutputScale(ctx) {
  160. var devicePixelRatio = window.devicePixelRatio || 1;
  161. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  162. var pixelRatio = devicePixelRatio / backingStoreRatio;
  163. return {
  164. sx: pixelRatio,
  165. sy: pixelRatio,
  166. scaled: pixelRatio !== 1
  167. };
  168. }
  169. function scrollIntoView(element, spot) {
  170. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  171. var parent = element.offsetParent;
  172. if (!parent) {
  173. console.error('offsetParent is not set -- cannot scroll');
  174. return;
  175. }
  176. var offsetY = element.offsetTop + element.clientTop;
  177. var offsetX = element.offsetLeft + element.clientLeft;
  178. while (parent.clientHeight === parent.scrollHeight || skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {
  179. if (parent.dataset._scaleY) {
  180. offsetY /= parent.dataset._scaleY;
  181. offsetX /= parent.dataset._scaleX;
  182. }
  183. offsetY += parent.offsetTop;
  184. offsetX += parent.offsetLeft;
  185. parent = parent.offsetParent;
  186. if (!parent) {
  187. return;
  188. }
  189. }
  190. if (spot) {
  191. if (spot.top !== undefined) {
  192. offsetY += spot.top;
  193. }
  194. if (spot.left !== undefined) {
  195. offsetX += spot.left;
  196. parent.scrollLeft = offsetX;
  197. }
  198. }
  199. parent.scrollTop = offsetY;
  200. }
  201. function watchScroll(viewAreaElement, callback) {
  202. var debounceScroll = function debounceScroll(evt) {
  203. if (rAF) {
  204. return;
  205. }
  206. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  207. rAF = null;
  208. var currentY = viewAreaElement.scrollTop;
  209. var lastY = state.lastY;
  210. if (currentY !== lastY) {
  211. state.down = currentY > lastY;
  212. }
  213. state.lastY = currentY;
  214. callback(state);
  215. });
  216. };
  217. var state = {
  218. down: true,
  219. lastY: viewAreaElement.scrollTop,
  220. _eventHandler: debounceScroll
  221. };
  222. var rAF = null;
  223. viewAreaElement.addEventListener('scroll', debounceScroll, true);
  224. return state;
  225. }
  226. function parseQueryString(query) {
  227. var parts = query.split('&');
  228. var params = Object.create(null);
  229. for (var i = 0, ii = parts.length; i < ii; ++i) {
  230. var param = parts[i].split('=');
  231. var key = param[0].toLowerCase();
  232. var value = param.length > 1 ? param[1] : null;
  233. params[decodeURIComponent(key)] = decodeURIComponent(value);
  234. }
  235. return params;
  236. }
  237. function binarySearchFirstItem(items, condition) {
  238. var minIndex = 0;
  239. var maxIndex = items.length - 1;
  240. if (items.length === 0 || !condition(items[maxIndex])) {
  241. return items.length;
  242. }
  243. if (condition(items[minIndex])) {
  244. return minIndex;
  245. }
  246. while (minIndex < maxIndex) {
  247. var currentIndex = minIndex + maxIndex >> 1;
  248. var currentItem = items[currentIndex];
  249. if (condition(currentItem)) {
  250. maxIndex = currentIndex;
  251. } else {
  252. minIndex = currentIndex + 1;
  253. }
  254. }
  255. return minIndex;
  256. }
  257. function approximateFraction(x) {
  258. if (Math.floor(x) === x) {
  259. return [x, 1];
  260. }
  261. var xinv = 1 / x;
  262. var limit = 8;
  263. if (xinv > limit) {
  264. return [1, limit];
  265. } else if (Math.floor(xinv) === xinv) {
  266. return [1, xinv];
  267. }
  268. var x_ = x > 1 ? xinv : x;
  269. var a = 0,
  270. b = 1,
  271. c = 1,
  272. d = 1;
  273. while (true) {
  274. var p = a + c,
  275. q = b + d;
  276. if (q > limit) {
  277. break;
  278. }
  279. if (x_ <= p / q) {
  280. c = p;
  281. d = q;
  282. } else {
  283. a = p;
  284. b = q;
  285. }
  286. }
  287. var result = void 0;
  288. if (x_ - a / b < c / d - x_) {
  289. result = x_ === x ? [a, b] : [b, a];
  290. } else {
  291. result = x_ === x ? [c, d] : [d, c];
  292. }
  293. return result;
  294. }
  295. function roundToDivide(x, div) {
  296. var r = x % div;
  297. return r === 0 ? x : Math.round(x - r + div);
  298. }
  299. function getVisibleElements(scrollEl, views) {
  300. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  301. var top = scrollEl.scrollTop,
  302. bottom = top + scrollEl.clientHeight;
  303. var left = scrollEl.scrollLeft,
  304. right = left + scrollEl.clientWidth;
  305. function isElementBottomBelowViewTop(view) {
  306. var element = view.div;
  307. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  308. return elementBottom > top;
  309. }
  310. var visible = [],
  311. view = void 0,
  312. element = void 0;
  313. var currentHeight = void 0,
  314. viewHeight = void 0,
  315. hiddenHeight = void 0,
  316. percentHeight = void 0;
  317. var currentWidth = void 0,
  318. viewWidth = void 0;
  319. var firstVisibleElementInd = views.length === 0 ? 0 : binarySearchFirstItem(views, isElementBottomBelowViewTop);
  320. for (var i = firstVisibleElementInd, ii = views.length; i < ii; i++) {
  321. view = views[i];
  322. element = view.div;
  323. currentHeight = element.offsetTop + element.clientTop;
  324. viewHeight = element.clientHeight;
  325. if (currentHeight > bottom) {
  326. break;
  327. }
  328. currentWidth = element.offsetLeft + element.clientLeft;
  329. viewWidth = element.clientWidth;
  330. if (currentWidth + viewWidth < left || currentWidth > right) {
  331. continue;
  332. }
  333. hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, currentHeight + viewHeight - bottom);
  334. percentHeight = (viewHeight - hiddenHeight) * 100 / viewHeight | 0;
  335. visible.push({
  336. id: view.id,
  337. x: currentWidth,
  338. y: currentHeight,
  339. view: view,
  340. percent: percentHeight
  341. });
  342. }
  343. var first = visible[0];
  344. var last = visible[visible.length - 1];
  345. if (sortByVisibility) {
  346. visible.sort(function (a, b) {
  347. var pc = a.percent - b.percent;
  348. if (Math.abs(pc) > 0.001) {
  349. return -pc;
  350. }
  351. return a.id - b.id;
  352. });
  353. }
  354. return {
  355. first: first,
  356. last: last,
  357. views: visible
  358. };
  359. }
  360. function noContextMenuHandler(evt) {
  361. evt.preventDefault();
  362. }
  363. function isDataSchema(url) {
  364. var i = 0,
  365. ii = url.length;
  366. while (i < ii && url[i].trim() === '') {
  367. i++;
  368. }
  369. return url.substr(i, 5).toLowerCase() === 'data:';
  370. }
  371. function getPDFFileNameFromURL(url) {
  372. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
  373. if (isDataSchema(url)) {
  374. console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
  375. return defaultFilename;
  376. }
  377. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  378. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  379. var splitURI = reURI.exec(url);
  380. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  381. if (suggestedFilename) {
  382. suggestedFilename = suggestedFilename[0];
  383. if (suggestedFilename.indexOf('%') !== -1) {
  384. try {
  385. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  386. } catch (ex) {}
  387. }
  388. }
  389. return suggestedFilename || defaultFilename;
  390. }
  391. function normalizeWheelEventDelta(evt) {
  392. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  393. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  394. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  395. delta = -delta;
  396. }
  397. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  398. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  399. var MOUSE_PIXELS_PER_LINE = 30;
  400. var MOUSE_LINES_PER_PAGE = 30;
  401. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  402. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  403. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  404. delta /= MOUSE_LINES_PER_PAGE;
  405. }
  406. return delta;
  407. }
  408. function isValidRotation(angle) {
  409. return Number.isInteger(angle) && angle % 90 === 0;
  410. }
  411. function cloneObj(obj) {
  412. var result = Object.create(null);
  413. for (var i in obj) {
  414. if (Object.prototype.hasOwnProperty.call(obj, i)) {
  415. result[i] = obj[i];
  416. }
  417. }
  418. return result;
  419. }
  420. var WaitOnType = {
  421. EVENT: 'event',
  422. TIMEOUT: 'timeout'
  423. };
  424. function waitOnEventOrTimeout(_ref) {
  425. var target = _ref.target,
  426. name = _ref.name,
  427. _ref$delay = _ref.delay,
  428. delay = _ref$delay === undefined ? 0 : _ref$delay;
  429. if ((typeof target === 'undefined' ? 'undefined' : _typeof(target)) !== 'object' || !(name && typeof name === 'string') || !(Number.isInteger(delay) && delay >= 0)) {
  430. return Promise.reject(new Error('waitOnEventOrTimeout - invalid paramaters.'));
  431. }
  432. var capability = (0, _pdfjsLib.createPromiseCapability)();
  433. function handler(type) {
  434. if (target instanceof EventBus) {
  435. target.off(name, eventHandler);
  436. } else {
  437. target.removeEventListener(name, eventHandler);
  438. }
  439. if (timeout) {
  440. clearTimeout(timeout);
  441. }
  442. capability.resolve(type);
  443. }
  444. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  445. if (target instanceof EventBus) {
  446. target.on(name, eventHandler);
  447. } else {
  448. target.addEventListener(name, eventHandler);
  449. }
  450. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  451. var timeout = setTimeout(timeoutHandler, delay);
  452. return capability.promise;
  453. }
  454. var animationStarted = new Promise(function (resolve) {
  455. window.requestAnimationFrame(resolve);
  456. });
  457. var mozL10n = void 0;
  458. var localized = Promise.resolve();
  459. var EventBus = function () {
  460. function EventBus() {
  461. _classCallCheck(this, EventBus);
  462. this._listeners = Object.create(null);
  463. }
  464. _createClass(EventBus, [{
  465. key: 'on',
  466. value: function on(eventName, listener) {
  467. var eventListeners = this._listeners[eventName];
  468. if (!eventListeners) {
  469. eventListeners = [];
  470. this._listeners[eventName] = eventListeners;
  471. }
  472. eventListeners.push(listener);
  473. }
  474. }, {
  475. key: 'off',
  476. value: function off(eventName, listener) {
  477. var eventListeners = this._listeners[eventName];
  478. var i = void 0;
  479. if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
  480. return;
  481. }
  482. eventListeners.splice(i, 1);
  483. }
  484. }, {
  485. key: 'dispatch',
  486. value: function dispatch(eventName) {
  487. var eventListeners = this._listeners[eventName];
  488. if (!eventListeners || eventListeners.length === 0) {
  489. return;
  490. }
  491. var args = Array.prototype.slice.call(arguments, 1);
  492. eventListeners.slice(0).forEach(function (listener) {
  493. listener.apply(null, args);
  494. });
  495. }
  496. }]);
  497. return EventBus;
  498. }();
  499. function clamp(v, min, max) {
  500. return Math.min(Math.max(v, min), max);
  501. }
  502. var ProgressBar = function () {
  503. function ProgressBar(id) {
  504. var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  505. height = _ref2.height,
  506. width = _ref2.width,
  507. units = _ref2.units;
  508. _classCallCheck(this, ProgressBar);
  509. this.visible = true;
  510. this.div = document.querySelector(id + ' .progress');
  511. this.bar = this.div.parentNode;
  512. this.height = height || 100;
  513. this.width = width || 100;
  514. this.units = units || '%';
  515. this.div.style.height = this.height + this.units;
  516. this.percent = 0;
  517. }
  518. _createClass(ProgressBar, [{
  519. key: '_updateBar',
  520. value: function _updateBar() {
  521. if (this._indeterminate) {
  522. this.div.classList.add('indeterminate');
  523. this.div.style.width = this.width + this.units;
  524. return;
  525. }
  526. this.div.classList.remove('indeterminate');
  527. var progressSize = this.width * this._percent / 100;
  528. this.div.style.width = progressSize + this.units;
  529. }
  530. }, {
  531. key: 'setWidth',
  532. value: function setWidth(viewer) {
  533. if (!viewer) {
  534. return;
  535. }
  536. var container = viewer.parentNode;
  537. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  538. if (scrollbarWidth > 0) {
  539. this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);');
  540. }
  541. }
  542. }, {
  543. key: 'hide',
  544. value: function hide() {
  545. if (!this.visible) {
  546. return;
  547. }
  548. this.visible = false;
  549. this.bar.classList.add('hidden');
  550. document.body.classList.remove('loadingInProgress');
  551. }
  552. }, {
  553. key: 'show',
  554. value: function show() {
  555. if (this.visible) {
  556. return;
  557. }
  558. this.visible = true;
  559. document.body.classList.add('loadingInProgress');
  560. this.bar.classList.remove('hidden');
  561. }
  562. }, {
  563. key: 'percent',
  564. get: function get() {
  565. return this._percent;
  566. },
  567. set: function set(val) {
  568. this._indeterminate = isNaN(val);
  569. this._percent = clamp(val, 0, 100);
  570. this._updateBar();
  571. }
  572. }]);
  573. return ProgressBar;
  574. }();
  575. exports.CSS_UNITS = CSS_UNITS;
  576. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  577. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  578. exports.MIN_SCALE = MIN_SCALE;
  579. exports.MAX_SCALE = MAX_SCALE;
  580. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  581. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  582. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  583. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  584. exports.isValidRotation = isValidRotation;
  585. exports.cloneObj = cloneObj;
  586. exports.PresentationModeState = PresentationModeState;
  587. exports.RendererType = RendererType;
  588. exports.mozL10n = mozL10n;
  589. exports.NullL10n = NullL10n;
  590. exports.EventBus = EventBus;
  591. exports.ProgressBar = ProgressBar;
  592. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  593. exports.noContextMenuHandler = noContextMenuHandler;
  594. exports.parseQueryString = parseQueryString;
  595. exports.getVisibleElements = getVisibleElements;
  596. exports.roundToDivide = roundToDivide;
  597. exports.approximateFraction = approximateFraction;
  598. exports.getOutputScale = getOutputScale;
  599. exports.scrollIntoView = scrollIntoView;
  600. exports.watchScroll = watchScroll;
  601. exports.binarySearchFirstItem = binarySearchFirstItem;
  602. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  603. exports.animationStarted = animationStarted;
  604. exports.localized = localized;
  605. exports.WaitOnType = WaitOnType;
  606. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  607. /***/ }),
  608. /* 2 */
  609. /***/ (function(module, exports, __w_pdfjs_require__) {
  610. "use strict";
  611. Object.defineProperty(exports, "__esModule", {
  612. value: true
  613. });
  614. exports.getGlobalEventBus = exports.attachDOMEventsToEventBus = undefined;
  615. var _ui_utils = __w_pdfjs_require__(1);
  616. function attachDOMEventsToEventBus(eventBus) {
  617. eventBus.on('documentload', function () {
  618. var event = document.createEvent('CustomEvent');
  619. event.initCustomEvent('documentload', true, true, {});
  620. window.dispatchEvent(event);
  621. });
  622. eventBus.on('pagerendered', function (evt) {
  623. var event = document.createEvent('CustomEvent');
  624. event.initCustomEvent('pagerendered', true, true, {
  625. pageNumber: evt.pageNumber,
  626. cssTransform: evt.cssTransform
  627. });
  628. evt.source.div.dispatchEvent(event);
  629. });
  630. eventBus.on('textlayerrendered', function (evt) {
  631. var event = document.createEvent('CustomEvent');
  632. event.initCustomEvent('textlayerrendered', true, true, { pageNumber: evt.pageNumber });
  633. evt.source.textLayerDiv.dispatchEvent(event);
  634. });
  635. eventBus.on('pagechange', function (evt) {
  636. var event = document.createEvent('UIEvents');
  637. event.initUIEvent('pagechange', true, true, window, 0);
  638. event.pageNumber = evt.pageNumber;
  639. evt.source.container.dispatchEvent(event);
  640. });
  641. eventBus.on('pagesinit', function (evt) {
  642. var event = document.createEvent('CustomEvent');
  643. event.initCustomEvent('pagesinit', true, true, null);
  644. evt.source.container.dispatchEvent(event);
  645. });
  646. eventBus.on('pagesloaded', function (evt) {
  647. var event = document.createEvent('CustomEvent');
  648. event.initCustomEvent('pagesloaded', true, true, { pagesCount: evt.pagesCount });
  649. evt.source.container.dispatchEvent(event);
  650. });
  651. eventBus.on('scalechange', function (evt) {
  652. var event = document.createEvent('UIEvents');
  653. event.initUIEvent('scalechange', true, true, window, 0);
  654. event.scale = evt.scale;
  655. event.presetValue = evt.presetValue;
  656. evt.source.container.dispatchEvent(event);
  657. });
  658. eventBus.on('updateviewarea', function (evt) {
  659. var event = document.createEvent('UIEvents');
  660. event.initUIEvent('updateviewarea', true, true, window, 0);
  661. event.location = evt.location;
  662. evt.source.container.dispatchEvent(event);
  663. });
  664. eventBus.on('find', function (evt) {
  665. if (evt.source === window) {
  666. return;
  667. }
  668. var event = document.createEvent('CustomEvent');
  669. event.initCustomEvent('find' + evt.type, true, true, {
  670. query: evt.query,
  671. phraseSearch: evt.phraseSearch,
  672. caseSensitive: evt.caseSensitive,
  673. highlightAll: evt.highlightAll,
  674. findPrevious: evt.findPrevious
  675. });
  676. window.dispatchEvent(event);
  677. });
  678. eventBus.on('attachmentsloaded', function (evt) {
  679. var event = document.createEvent('CustomEvent');
  680. event.initCustomEvent('attachmentsloaded', true, true, { attachmentsCount: evt.attachmentsCount });
  681. evt.source.container.dispatchEvent(event);
  682. });
  683. eventBus.on('sidebarviewchanged', function (evt) {
  684. var event = document.createEvent('CustomEvent');
  685. event.initCustomEvent('sidebarviewchanged', true, true, { view: evt.view });
  686. evt.source.outerContainer.dispatchEvent(event);
  687. });
  688. eventBus.on('pagemode', function (evt) {
  689. var event = document.createEvent('CustomEvent');
  690. event.initCustomEvent('pagemode', true, true, { mode: evt.mode });
  691. evt.source.pdfViewer.container.dispatchEvent(event);
  692. });
  693. eventBus.on('namedaction', function (evt) {
  694. var event = document.createEvent('CustomEvent');
  695. event.initCustomEvent('namedaction', true, true, { action: evt.action });
  696. evt.source.pdfViewer.container.dispatchEvent(event);
  697. });
  698. eventBus.on('presentationmodechanged', function (evt) {
  699. var event = document.createEvent('CustomEvent');
  700. event.initCustomEvent('presentationmodechanged', true, true, {
  701. active: evt.active,
  702. switchInProgress: evt.switchInProgress
  703. });
  704. window.dispatchEvent(event);
  705. });
  706. eventBus.on('outlineloaded', function (evt) {
  707. var event = document.createEvent('CustomEvent');
  708. event.initCustomEvent('outlineloaded', true, true, { outlineCount: evt.outlineCount });
  709. evt.source.container.dispatchEvent(event);
  710. });
  711. }
  712. var globalEventBus = null;
  713. function getGlobalEventBus() {
  714. if (globalEventBus) {
  715. return globalEventBus;
  716. }
  717. globalEventBus = new _ui_utils.EventBus();
  718. attachDOMEventsToEventBus(globalEventBus);
  719. return globalEventBus;
  720. }
  721. exports.attachDOMEventsToEventBus = attachDOMEventsToEventBus;
  722. exports.getGlobalEventBus = getGlobalEventBus;
  723. /***/ }),
  724. /* 3 */
  725. /***/ (function(module, exports, __w_pdfjs_require__) {
  726. "use strict";
  727. Object.defineProperty(exports, "__esModule", {
  728. value: true
  729. });
  730. exports.SimpleLinkService = exports.PDFLinkService = undefined;
  731. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  732. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  733. var _dom_events = __w_pdfjs_require__(2);
  734. var _ui_utils = __w_pdfjs_require__(1);
  735. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  736. var PDFLinkService = function () {
  737. function PDFLinkService() {
  738. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  739. eventBus = _ref.eventBus;
  740. _classCallCheck(this, PDFLinkService);
  741. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  742. this.baseUrl = null;
  743. this.pdfDocument = null;
  744. this.pdfViewer = null;
  745. this.pdfHistory = null;
  746. this._pagesRefCache = null;
  747. }
  748. _createClass(PDFLinkService, [{
  749. key: 'setDocument',
  750. value: function setDocument(pdfDocument, baseUrl) {
  751. this.baseUrl = baseUrl;
  752. this.pdfDocument = pdfDocument;
  753. this._pagesRefCache = Object.create(null);
  754. }
  755. }, {
  756. key: 'setViewer',
  757. value: function setViewer(pdfViewer) {
  758. this.pdfViewer = pdfViewer;
  759. }
  760. }, {
  761. key: 'setHistory',
  762. value: function setHistory(pdfHistory) {
  763. this.pdfHistory = pdfHistory;
  764. }
  765. }, {
  766. key: 'navigateTo',
  767. value: function navigateTo(dest) {
  768. var _this = this;
  769. var goToDestination = function goToDestination(_ref2) {
  770. var namedDest = _ref2.namedDest,
  771. explicitDest = _ref2.explicitDest;
  772. var destRef = explicitDest[0],
  773. pageNumber = void 0;
  774. if (destRef instanceof Object) {
  775. pageNumber = _this._cachedPageNumber(destRef);
  776. if (pageNumber === null) {
  777. _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  778. _this.cachePageRef(pageIndex + 1, destRef);
  779. goToDestination({
  780. namedDest: namedDest,
  781. explicitDest: explicitDest
  782. });
  783. }).catch(function () {
  784. console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid page reference, for dest="' + dest + '".'));
  785. });
  786. return;
  787. }
  788. } else if (Number.isInteger(destRef)) {
  789. pageNumber = destRef + 1;
  790. } else {
  791. console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid destination reference, for dest="' + dest + '".'));
  792. return;
  793. }
  794. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  795. console.error('PDFLinkService.navigateTo: "' + pageNumber + '" is not ' + ('a valid page number, for dest="' + dest + '".'));
  796. return;
  797. }
  798. if (_this.pdfHistory) {
  799. _this.pdfHistory.pushCurrentPosition();
  800. _this.pdfHistory.push({
  801. namedDest: namedDest,
  802. explicitDest: explicitDest,
  803. pageNumber: pageNumber
  804. });
  805. }
  806. _this.pdfViewer.scrollPageIntoView({
  807. pageNumber: pageNumber,
  808. destArray: explicitDest
  809. });
  810. };
  811. new Promise(function (resolve, reject) {
  812. if (typeof dest === 'string') {
  813. _this.pdfDocument.getDestination(dest).then(function (destArray) {
  814. resolve({
  815. namedDest: dest,
  816. explicitDest: destArray
  817. });
  818. });
  819. return;
  820. }
  821. resolve({
  822. namedDest: '',
  823. explicitDest: dest
  824. });
  825. }).then(function (data) {
  826. if (!(data.explicitDest instanceof Array)) {
  827. console.error('PDFLinkService.navigateTo: "' + data.explicitDest + '" is' + (' not a valid destination array, for dest="' + dest + '".'));
  828. return;
  829. }
  830. goToDestination(data);
  831. });
  832. }
  833. }, {
  834. key: 'getDestinationHash',
  835. value: function getDestinationHash(dest) {
  836. if (typeof dest === 'string') {
  837. return this.getAnchorUrl('#' + escape(dest));
  838. }
  839. if (dest instanceof Array) {
  840. var str = JSON.stringify(dest);
  841. return this.getAnchorUrl('#' + escape(str));
  842. }
  843. return this.getAnchorUrl('');
  844. }
  845. }, {
  846. key: 'getAnchorUrl',
  847. value: function getAnchorUrl(anchor) {
  848. return (this.baseUrl || '') + anchor;
  849. }
  850. }, {
  851. key: 'setHash',
  852. value: function setHash(hash) {
  853. var pageNumber = void 0,
  854. dest = void 0;
  855. if (hash.indexOf('=') >= 0) {
  856. var params = (0, _ui_utils.parseQueryString)(hash);
  857. if ('search' in params) {
  858. this.eventBus.dispatch('findfromurlhash', {
  859. source: this,
  860. query: params['search'].replace(/"/g, ''),
  861. phraseSearch: params['phrase'] === 'true'
  862. });
  863. }
  864. if ('nameddest' in params) {
  865. this.navigateTo(params.nameddest);
  866. return;
  867. }
  868. if ('page' in params) {
  869. pageNumber = params.page | 0 || 1;
  870. }
  871. if ('zoom' in params) {
  872. var zoomArgs = params.zoom.split(',');
  873. var zoomArg = zoomArgs[0];
  874. var zoomArgNumber = parseFloat(zoomArg);
  875. if (zoomArg.indexOf('Fit') === -1) {
  876. dest = [null, { name: 'XYZ' }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  877. } else {
  878. if (zoomArg === 'Fit' || zoomArg === 'FitB') {
  879. dest = [null, { name: zoomArg }];
  880. } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || zoomArg === 'FitV' || zoomArg === 'FitBV') {
  881. dest = [null, { name: zoomArg }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  882. } else if (zoomArg === 'FitR') {
  883. if (zoomArgs.length !== 5) {
  884. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  885. } else {
  886. dest = [null, { name: zoomArg }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  887. }
  888. } else {
  889. console.error('PDFLinkService.setHash: "' + zoomArg + '" is not ' + 'a valid zoom value.');
  890. }
  891. }
  892. }
  893. if (dest) {
  894. this.pdfViewer.scrollPageIntoView({
  895. pageNumber: pageNumber || this.page,
  896. destArray: dest,
  897. allowNegativeOffset: true
  898. });
  899. } else if (pageNumber) {
  900. this.page = pageNumber;
  901. }
  902. if ('pagemode' in params) {
  903. this.eventBus.dispatch('pagemode', {
  904. source: this,
  905. mode: params.pagemode
  906. });
  907. }
  908. } else {
  909. dest = unescape(hash);
  910. try {
  911. dest = JSON.parse(dest);
  912. if (!(dest instanceof Array)) {
  913. dest = dest.toString();
  914. }
  915. } catch (ex) {}
  916. if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
  917. this.navigateTo(dest);
  918. return;
  919. }
  920. console.error('PDFLinkService.setHash: "' + unescape(hash) + '" is not ' + 'a valid destination.');
  921. }
  922. }
  923. }, {
  924. key: 'executeNamedAction',
  925. value: function executeNamedAction(action) {
  926. switch (action) {
  927. case 'GoBack':
  928. if (this.pdfHistory) {
  929. this.pdfHistory.back();
  930. }
  931. break;
  932. case 'GoForward':
  933. if (this.pdfHistory) {
  934. this.pdfHistory.forward();
  935. }
  936. break;
  937. case 'NextPage':
  938. if (this.page < this.pagesCount) {
  939. this.page++;
  940. }
  941. break;
  942. case 'PrevPage':
  943. if (this.page > 1) {
  944. this.page--;
  945. }
  946. break;
  947. case 'LastPage':
  948. this.page = this.pagesCount;
  949. break;
  950. case 'FirstPage':
  951. this.page = 1;
  952. break;
  953. default:
  954. break;
  955. }
  956. this.eventBus.dispatch('namedaction', {
  957. source: this,
  958. action: action
  959. });
  960. }
  961. }, {
  962. key: 'onFileAttachmentAnnotation',
  963. value: function onFileAttachmentAnnotation(_ref3) {
  964. var id = _ref3.id,
  965. filename = _ref3.filename,
  966. content = _ref3.content;
  967. this.eventBus.dispatch('fileattachmentannotation', {
  968. source: this,
  969. id: id,
  970. filename: filename,
  971. content: content
  972. });
  973. }
  974. }, {
  975. key: 'cachePageRef',
  976. value: function cachePageRef(pageNum, pageRef) {
  977. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  978. this._pagesRefCache[refStr] = pageNum;
  979. }
  980. }, {
  981. key: '_cachedPageNumber',
  982. value: function _cachedPageNumber(pageRef) {
  983. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  984. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  985. }
  986. }, {
  987. key: 'pagesCount',
  988. get: function get() {
  989. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  990. }
  991. }, {
  992. key: 'page',
  993. get: function get() {
  994. return this.pdfViewer.currentPageNumber;
  995. },
  996. set: function set(value) {
  997. this.pdfViewer.currentPageNumber = value;
  998. }
  999. }, {
  1000. key: 'rotation',
  1001. get: function get() {
  1002. return this.pdfViewer.pagesRotation;
  1003. },
  1004. set: function set(value) {
  1005. this.pdfViewer.pagesRotation = value;
  1006. }
  1007. }]);
  1008. return PDFLinkService;
  1009. }();
  1010. function isValidExplicitDestination(dest) {
  1011. if (!(dest instanceof Array)) {
  1012. return false;
  1013. }
  1014. var destLength = dest.length,
  1015. allowNull = true;
  1016. if (destLength < 2) {
  1017. return false;
  1018. }
  1019. var page = dest[0];
  1020. if (!((typeof page === 'undefined' ? 'undefined' : _typeof(page)) === 'object' && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  1021. return false;
  1022. }
  1023. var zoom = dest[1];
  1024. if (!((typeof zoom === 'undefined' ? 'undefined' : _typeof(zoom)) === 'object' && typeof zoom.name === 'string')) {
  1025. return false;
  1026. }
  1027. switch (zoom.name) {
  1028. case 'XYZ':
  1029. if (destLength !== 5) {
  1030. return false;
  1031. }
  1032. break;
  1033. case 'Fit':
  1034. case 'FitB':
  1035. return destLength === 2;
  1036. case 'FitH':
  1037. case 'FitBH':
  1038. case 'FitV':
  1039. case 'FitBV':
  1040. if (destLength !== 3) {
  1041. return false;
  1042. }
  1043. break;
  1044. case 'FitR':
  1045. if (destLength !== 6) {
  1046. return false;
  1047. }
  1048. allowNull = false;
  1049. break;
  1050. default:
  1051. return false;
  1052. }
  1053. for (var i = 2; i < destLength; i++) {
  1054. var param = dest[i];
  1055. if (!(typeof param === 'number' || allowNull && param === null)) {
  1056. return false;
  1057. }
  1058. }
  1059. return true;
  1060. }
  1061. var SimpleLinkService = function () {
  1062. function SimpleLinkService() {
  1063. _classCallCheck(this, SimpleLinkService);
  1064. }
  1065. _createClass(SimpleLinkService, [{
  1066. key: 'navigateTo',
  1067. value: function navigateTo(dest) {}
  1068. }, {
  1069. key: 'getDestinationHash',
  1070. value: function getDestinationHash(dest) {
  1071. return '#';
  1072. }
  1073. }, {
  1074. key: 'getAnchorUrl',
  1075. value: function getAnchorUrl(hash) {
  1076. return '#';
  1077. }
  1078. }, {
  1079. key: 'setHash',
  1080. value: function setHash(hash) {}
  1081. }, {
  1082. key: 'executeNamedAction',
  1083. value: function executeNamedAction(action) {}
  1084. }, {
  1085. key: 'onFileAttachmentAnnotation',
  1086. value: function onFileAttachmentAnnotation(_ref4) {
  1087. var id = _ref4.id,
  1088. filename = _ref4.filename,
  1089. content = _ref4.content;
  1090. }
  1091. }, {
  1092. key: 'cachePageRef',
  1093. value: function cachePageRef(pageNum, pageRef) {}
  1094. }, {
  1095. key: 'page',
  1096. get: function get() {
  1097. return 0;
  1098. },
  1099. set: function set(value) {}
  1100. }, {
  1101. key: 'rotation',
  1102. get: function get() {
  1103. return 0;
  1104. },
  1105. set: function set(value) {}
  1106. }]);
  1107. return SimpleLinkService;
  1108. }();
  1109. exports.PDFLinkService = PDFLinkService;
  1110. exports.SimpleLinkService = SimpleLinkService;
  1111. /***/ }),
  1112. /* 4 */
  1113. /***/ (function(module, exports, __w_pdfjs_require__) {
  1114. "use strict";
  1115. Object.defineProperty(exports, "__esModule", {
  1116. value: true
  1117. });
  1118. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = undefined;
  1119. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1120. var _pdfjsLib = __w_pdfjs_require__(0);
  1121. var _ui_utils = __w_pdfjs_require__(1);
  1122. var _pdf_link_service = __w_pdfjs_require__(3);
  1123. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1124. var AnnotationLayerBuilder = function () {
  1125. function AnnotationLayerBuilder(_ref) {
  1126. var pageDiv = _ref.pageDiv,
  1127. pdfPage = _ref.pdfPage,
  1128. linkService = _ref.linkService,
  1129. downloadManager = _ref.downloadManager,
  1130. _ref$renderInteractiv = _ref.renderInteractiveForms,
  1131. renderInteractiveForms = _ref$renderInteractiv === undefined ? false : _ref$renderInteractiv,
  1132. _ref$l10n = _ref.l10n,
  1133. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n;
  1134. _classCallCheck(this, AnnotationLayerBuilder);
  1135. this.pageDiv = pageDiv;
  1136. this.pdfPage = pdfPage;
  1137. this.linkService = linkService;
  1138. this.downloadManager = downloadManager;
  1139. this.renderInteractiveForms = renderInteractiveForms;
  1140. this.l10n = l10n;
  1141. this.div = null;
  1142. this._cancelled = false;
  1143. }
  1144. _createClass(AnnotationLayerBuilder, [{
  1145. key: 'render',
  1146. value: function render(viewport) {
  1147. var _this = this;
  1148. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';
  1149. this.pdfPage.getAnnotations({ intent: intent }).then(function (annotations) {
  1150. if (_this._cancelled) {
  1151. return;
  1152. }
  1153. var parameters = {
  1154. viewport: viewport.clone({ dontFlip: true }),
  1155. div: _this.div,
  1156. annotations: annotations,
  1157. page: _this.pdfPage,
  1158. renderInteractiveForms: _this.renderInteractiveForms,
  1159. linkService: _this.linkService,
  1160. downloadManager: _this.downloadManager
  1161. };
  1162. if (_this.div) {
  1163. _pdfjsLib.AnnotationLayer.update(parameters);
  1164. } else {
  1165. if (annotations.length === 0) {
  1166. return;
  1167. }
  1168. _this.div = document.createElement('div');
  1169. _this.div.className = 'annotationLayer';
  1170. _this.pageDiv.appendChild(_this.div);
  1171. parameters.div = _this.div;
  1172. _pdfjsLib.AnnotationLayer.render(parameters);
  1173. _this.l10n.translate(_this.div);
  1174. }
  1175. });
  1176. }
  1177. }, {
  1178. key: 'cancel',
  1179. value: function cancel() {
  1180. this._cancelled = true;
  1181. }
  1182. }, {
  1183. key: 'hide',
  1184. value: function hide() {
  1185. if (!this.div) {
  1186. return;
  1187. }
  1188. this.div.setAttribute('hidden', 'true');
  1189. }
  1190. }]);
  1191. return AnnotationLayerBuilder;
  1192. }();
  1193. var DefaultAnnotationLayerFactory = function () {
  1194. function DefaultAnnotationLayerFactory() {
  1195. _classCallCheck(this, DefaultAnnotationLayerFactory);
  1196. }
  1197. _createClass(DefaultAnnotationLayerFactory, [{
  1198. key: 'createAnnotationLayerBuilder',
  1199. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  1200. var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  1201. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  1202. return new AnnotationLayerBuilder({
  1203. pageDiv: pageDiv,
  1204. pdfPage: pdfPage,
  1205. renderInteractiveForms: renderInteractiveForms,
  1206. linkService: new _pdf_link_service.SimpleLinkService(),
  1207. l10n: l10n
  1208. });
  1209. }
  1210. }]);
  1211. return DefaultAnnotationLayerFactory;
  1212. }();
  1213. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  1214. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  1215. /***/ }),
  1216. /* 5 */
  1217. /***/ (function(module, exports, __w_pdfjs_require__) {
  1218. "use strict";
  1219. Object.defineProperty(exports, "__esModule", {
  1220. value: true
  1221. });
  1222. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = undefined;
  1223. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1224. var _dom_events = __w_pdfjs_require__(2);
  1225. var _pdfjsLib = __w_pdfjs_require__(0);
  1226. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1227. var EXPAND_DIVS_TIMEOUT = 300;
  1228. var TextLayerBuilder = function () {
  1229. function TextLayerBuilder(_ref) {
  1230. var textLayerDiv = _ref.textLayerDiv,
  1231. eventBus = _ref.eventBus,
  1232. pageIndex = _ref.pageIndex,
  1233. viewport = _ref.viewport,
  1234. _ref$findController = _ref.findController,
  1235. findController = _ref$findController === undefined ? null : _ref$findController,
  1236. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  1237. enhanceTextSelection = _ref$enhanceTextSelec === undefined ? false : _ref$enhanceTextSelec;
  1238. _classCallCheck(this, TextLayerBuilder);
  1239. this.textLayerDiv = textLayerDiv;
  1240. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  1241. this.textContent = null;
  1242. this.textContentItemsStr = [];
  1243. this.textContentStream = null;
  1244. this.renderingDone = false;
  1245. this.pageIdx = pageIndex;
  1246. this.pageNumber = this.pageIdx + 1;
  1247. this.matches = [];
  1248. this.viewport = viewport;
  1249. this.textDivs = [];
  1250. this.findController = findController;
  1251. this.textLayerRenderTask = null;
  1252. this.enhanceTextSelection = enhanceTextSelection;
  1253. this._bindMouse();
  1254. }
  1255. _createClass(TextLayerBuilder, [{
  1256. key: '_finishRendering',
  1257. value: function _finishRendering() {
  1258. this.renderingDone = true;
  1259. if (!this.enhanceTextSelection) {
  1260. var endOfContent = document.createElement('div');
  1261. endOfContent.className = 'endOfContent';
  1262. this.textLayerDiv.appendChild(endOfContent);
  1263. }
  1264. this.eventBus.dispatch('textlayerrendered', {
  1265. source: this,
  1266. pageNumber: this.pageNumber,
  1267. numTextDivs: this.textDivs.length
  1268. });
  1269. }
  1270. }, {
  1271. key: 'render',
  1272. value: function render() {
  1273. var _this = this;
  1274. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1275. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  1276. return;
  1277. }
  1278. this.cancel();
  1279. this.textDivs = [];
  1280. var textLayerFrag = document.createDocumentFragment();
  1281. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  1282. textContent: this.textContent,
  1283. textContentStream: this.textContentStream,
  1284. container: textLayerFrag,
  1285. viewport: this.viewport,
  1286. textDivs: this.textDivs,
  1287. textContentItemsStr: this.textContentItemsStr,
  1288. timeout: timeout,
  1289. enhanceTextSelection: this.enhanceTextSelection
  1290. });
  1291. this.textLayerRenderTask.promise.then(function () {
  1292. _this.textLayerDiv.appendChild(textLayerFrag);
  1293. _this._finishRendering();
  1294. _this.updateMatches();
  1295. }, function (reason) {});
  1296. }
  1297. }, {
  1298. key: 'cancel',
  1299. value: function cancel() {
  1300. if (this.textLayerRenderTask) {
  1301. this.textLayerRenderTask.cancel();
  1302. this.textLayerRenderTask = null;
  1303. }
  1304. }
  1305. }, {
  1306. key: 'setTextContentStream',
  1307. value: function setTextContentStream(readableStream) {
  1308. this.cancel();
  1309. this.textContentStream = readableStream;
  1310. }
  1311. }, {
  1312. key: 'setTextContent',
  1313. value: function setTextContent(textContent) {
  1314. this.cancel();
  1315. this.textContent = textContent;
  1316. }
  1317. }, {
  1318. key: 'convertMatches',
  1319. value: function convertMatches(matches, matchesLength) {
  1320. var i = 0;
  1321. var iIndex = 0;
  1322. var textContentItemsStr = this.textContentItemsStr;
  1323. var end = textContentItemsStr.length - 1;
  1324. var queryLen = this.findController === null ? 0 : this.findController.state.query.length;
  1325. var ret = [];
  1326. if (!matches) {
  1327. return ret;
  1328. }
  1329. for (var m = 0, len = matches.length; m < len; m++) {
  1330. var matchIdx = matches[m];
  1331. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  1332. iIndex += textContentItemsStr[i].length;
  1333. i++;
  1334. }
  1335. if (i === textContentItemsStr.length) {
  1336. console.error('Could not find a matching mapping');
  1337. }
  1338. var match = {
  1339. begin: {
  1340. divIdx: i,
  1341. offset: matchIdx - iIndex
  1342. }
  1343. };
  1344. if (matchesLength) {
  1345. matchIdx += matchesLength[m];
  1346. } else {
  1347. matchIdx += queryLen;
  1348. }
  1349. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  1350. iIndex += textContentItemsStr[i].length;
  1351. i++;
  1352. }
  1353. match.end = {
  1354. divIdx: i,
  1355. offset: matchIdx - iIndex
  1356. };
  1357. ret.push(match);
  1358. }
  1359. return ret;
  1360. }
  1361. }, {
  1362. key: 'renderMatches',
  1363. value: function renderMatches(matches) {
  1364. if (matches.length === 0) {
  1365. return;
  1366. }
  1367. var textContentItemsStr = this.textContentItemsStr;
  1368. var textDivs = this.textDivs;
  1369. var prevEnd = null;
  1370. var pageIdx = this.pageIdx;
  1371. var isSelectedPage = this.findController === null ? false : pageIdx === this.findController.selected.pageIdx;
  1372. var selectedMatchIdx = this.findController === null ? -1 : this.findController.selected.matchIdx;
  1373. var highlightAll = this.findController === null ? false : this.findController.state.highlightAll;
  1374. var infinity = {
  1375. divIdx: -1,
  1376. offset: undefined
  1377. };
  1378. function beginText(begin, className) {
  1379. var divIdx = begin.divIdx;
  1380. textDivs[divIdx].textContent = '';
  1381. appendTextToDiv(divIdx, 0, begin.offset, className);
  1382. }
  1383. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  1384. var div = textDivs[divIdx];
  1385. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  1386. var node = document.createTextNode(content);
  1387. if (className) {
  1388. var span = document.createElement('span');
  1389. span.className = className;
  1390. span.appendChild(node);
  1391. div.appendChild(span);
  1392. return;
  1393. }
  1394. div.appendChild(node);
  1395. }
  1396. var i0 = selectedMatchIdx,
  1397. i1 = i0 + 1;
  1398. if (highlightAll) {
  1399. i0 = 0;
  1400. i1 = matches.length;
  1401. } else if (!isSelectedPage) {
  1402. return;
  1403. }
  1404. for (var i = i0; i < i1; i++) {
  1405. var match = matches[i];
  1406. var begin = match.begin;
  1407. var end = match.end;
  1408. var isSelected = isSelectedPage && i === selectedMatchIdx;
  1409. var highlightSuffix = isSelected ? ' selected' : '';
  1410. if (this.findController) {
  1411. this.findController.updateMatchPosition(pageIdx, i, textDivs, begin.divIdx);
  1412. }
  1413. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  1414. if (prevEnd !== null) {
  1415. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  1416. }
  1417. beginText(begin);
  1418. } else {
  1419. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  1420. }
  1421. if (begin.divIdx === end.divIdx) {
  1422. appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix);
  1423. } else {
  1424. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix);
  1425. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  1426. textDivs[n0].className = 'highlight middle' + highlightSuffix;
  1427. }
  1428. beginText(end, 'highlight end' + highlightSuffix);
  1429. }
  1430. prevEnd = end;
  1431. }
  1432. if (prevEnd) {
  1433. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  1434. }
  1435. }
  1436. }, {
  1437. key: 'updateMatches',
  1438. value: function updateMatches() {
  1439. if (!this.renderingDone) {
  1440. return;
  1441. }
  1442. var matches = this.matches;
  1443. var textDivs = this.textDivs;
  1444. var textContentItemsStr = this.textContentItemsStr;
  1445. var clearedUntilDivIdx = -1;
  1446. for (var i = 0, len = matches.length; i < len; i++) {
  1447. var match = matches[i];
  1448. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  1449. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  1450. var div = textDivs[n];
  1451. div.textContent = textContentItemsStr[n];
  1452. div.className = '';
  1453. }
  1454. clearedUntilDivIdx = match.end.divIdx + 1;
  1455. }
  1456. if (this.findController === null || !this.findController.active) {
  1457. return;
  1458. }
  1459. var pageMatches = void 0,
  1460. pageMatchesLength = void 0;
  1461. if (this.findController !== null) {
  1462. pageMatches = this.findController.pageMatches[this.pageIdx] || null;
  1463. pageMatchesLength = this.findController.pageMatchesLength ? this.findController.pageMatchesLength[this.pageIdx] || null : null;
  1464. }
  1465. this.matches = this.convertMatches(pageMatches, pageMatchesLength);
  1466. this.renderMatches(this.matches);
  1467. }
  1468. }, {
  1469. key: '_bindMouse',
  1470. value: function _bindMouse() {
  1471. var _this2 = this;
  1472. var div = this.textLayerDiv;
  1473. var expandDivsTimer = null;
  1474. div.addEventListener('mousedown', function (evt) {
  1475. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  1476. _this2.textLayerRenderTask.expandTextDivs(true);
  1477. if (expandDivsTimer) {
  1478. clearTimeout(expandDivsTimer);
  1479. expandDivsTimer = null;
  1480. }
  1481. return;
  1482. }
  1483. var end = div.querySelector('.endOfContent');
  1484. if (!end) {
  1485. return;
  1486. }
  1487. var adjustTop = evt.target !== div;
  1488. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';
  1489. if (adjustTop) {
  1490. var divBounds = div.getBoundingClientRect();
  1491. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  1492. end.style.top = (r * 100).toFixed(2) + '%';
  1493. }
  1494. end.classList.add('active');
  1495. });
  1496. div.addEventListener('mouseup', function () {
  1497. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  1498. expandDivsTimer = setTimeout(function () {
  1499. if (_this2.textLayerRenderTask) {
  1500. _this2.textLayerRenderTask.expandTextDivs(false);
  1501. }
  1502. expandDivsTimer = null;
  1503. }, EXPAND_DIVS_TIMEOUT);
  1504. return;
  1505. }
  1506. var end = div.querySelector('.endOfContent');
  1507. if (!end) {
  1508. return;
  1509. }
  1510. end.style.top = '';
  1511. end.classList.remove('active');
  1512. });
  1513. }
  1514. }]);
  1515. return TextLayerBuilder;
  1516. }();
  1517. var DefaultTextLayerFactory = function () {
  1518. function DefaultTextLayerFactory() {
  1519. _classCallCheck(this, DefaultTextLayerFactory);
  1520. }
  1521. _createClass(DefaultTextLayerFactory, [{
  1522. key: 'createTextLayerBuilder',
  1523. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  1524. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  1525. return new TextLayerBuilder({
  1526. textLayerDiv: textLayerDiv,
  1527. pageIndex: pageIndex,
  1528. viewport: viewport,
  1529. enhanceTextSelection: enhanceTextSelection
  1530. });
  1531. }
  1532. }]);
  1533. return DefaultTextLayerFactory;
  1534. }();
  1535. exports.TextLayerBuilder = TextLayerBuilder;
  1536. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  1537. /***/ }),
  1538. /* 6 */
  1539. /***/ (function(module, exports, __w_pdfjs_require__) {
  1540. "use strict";
  1541. Object.defineProperty(exports, "__esModule", {
  1542. value: true
  1543. });
  1544. exports.PDFPageView = undefined;
  1545. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1546. var _ui_utils = __w_pdfjs_require__(1);
  1547. var _pdfjsLib = __w_pdfjs_require__(0);
  1548. var _dom_events = __w_pdfjs_require__(2);
  1549. var _pdf_rendering_queue = __w_pdfjs_require__(7);
  1550. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1551. var PDFPageView = function () {
  1552. function PDFPageView(options) {
  1553. _classCallCheck(this, PDFPageView);
  1554. var container = options.container;
  1555. var defaultViewport = options.defaultViewport;
  1556. this.id = options.id;
  1557. this.renderingId = 'page' + this.id;
  1558. this.pdfPage = null;
  1559. this.pageLabel = null;
  1560. this.rotation = 0;
  1561. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  1562. this.viewport = defaultViewport;
  1563. this.pdfPageRotate = defaultViewport.rotation;
  1564. this.hasRestrictedScaling = false;
  1565. this.enhanceTextSelection = options.enhanceTextSelection || false;
  1566. this.renderInteractiveForms = options.renderInteractiveForms || false;
  1567. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  1568. this.renderingQueue = options.renderingQueue;
  1569. this.textLayerFactory = options.textLayerFactory;
  1570. this.annotationLayerFactory = options.annotationLayerFactory;
  1571. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  1572. this.l10n = options.l10n || _ui_utils.NullL10n;
  1573. this.paintTask = null;
  1574. this.paintedViewportMap = new WeakMap();
  1575. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  1576. this.resume = null;
  1577. this.error = null;
  1578. this.onBeforeDraw = null;
  1579. this.onAfterDraw = null;
  1580. this.annotationLayer = null;
  1581. this.textLayer = null;
  1582. this.zoomLayer = null;
  1583. var div = document.createElement('div');
  1584. div.className = 'page';
  1585. div.style.width = Math.floor(this.viewport.width) + 'px';
  1586. div.style.height = Math.floor(this.viewport.height) + 'px';
  1587. div.setAttribute('data-page-number', this.id);
  1588. this.div = div;
  1589. container.appendChild(div);
  1590. }
  1591. _createClass(PDFPageView, [{
  1592. key: 'setPdfPage',
  1593. value: function setPdfPage(pdfPage) {
  1594. this.pdfPage = pdfPage;
  1595. this.pdfPageRotate = pdfPage.rotate;
  1596. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  1597. this.viewport = pdfPage.getViewport(this.scale * _ui_utils.CSS_UNITS, totalRotation);
  1598. this.stats = pdfPage.stats;
  1599. this.reset();
  1600. }
  1601. }, {
  1602. key: 'destroy',
  1603. value: function destroy() {
  1604. this.reset();
  1605. if (this.pdfPage) {
  1606. this.pdfPage.cleanup();
  1607. }
  1608. }
  1609. }, {
  1610. key: '_resetZoomLayer',
  1611. value: function _resetZoomLayer() {
  1612. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1613. if (!this.zoomLayer) {
  1614. return;
  1615. }
  1616. var zoomLayerCanvas = this.zoomLayer.firstChild;
  1617. this.paintedViewportMap.delete(zoomLayerCanvas);
  1618. zoomLayerCanvas.width = 0;
  1619. zoomLayerCanvas.height = 0;
  1620. if (removeFromDOM) {
  1621. this.zoomLayer.remove();
  1622. }
  1623. this.zoomLayer = null;
  1624. }
  1625. }, {
  1626. key: 'reset',
  1627. value: function reset() {
  1628. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1629. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  1630. this.cancelRendering(keepAnnotations);
  1631. var div = this.div;
  1632. div.style.width = Math.floor(this.viewport.width) + 'px';
  1633. div.style.height = Math.floor(this.viewport.height) + 'px';
  1634. var childNodes = div.childNodes;
  1635. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  1636. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  1637. for (var i = childNodes.length - 1; i >= 0; i--) {
  1638. var node = childNodes[i];
  1639. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  1640. continue;
  1641. }
  1642. div.removeChild(node);
  1643. }
  1644. div.removeAttribute('data-loaded');
  1645. if (currentAnnotationNode) {
  1646. this.annotationLayer.hide();
  1647. } else if (this.annotationLayer) {
  1648. this.annotationLayer.cancel();
  1649. this.annotationLayer = null;
  1650. }
  1651. if (!currentZoomLayerNode) {
  1652. if (this.canvas) {
  1653. this.paintedViewportMap.delete(this.canvas);
  1654. this.canvas.width = 0;
  1655. this.canvas.height = 0;
  1656. delete this.canvas;
  1657. }
  1658. this._resetZoomLayer();
  1659. }
  1660. if (this.svg) {
  1661. this.paintedViewportMap.delete(this.svg);
  1662. delete this.svg;
  1663. }
  1664. this.loadingIconDiv = document.createElement('div');
  1665. this.loadingIconDiv.className = 'loadingIcon';
  1666. div.appendChild(this.loadingIconDiv);
  1667. }
  1668. }, {
  1669. key: 'update',
  1670. value: function update(scale, rotation) {
  1671. this.scale = scale || this.scale;
  1672. if (typeof rotation !== 'undefined') {
  1673. this.rotation = rotation;
  1674. }
  1675. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  1676. this.viewport = this.viewport.clone({
  1677. scale: this.scale * _ui_utils.CSS_UNITS,
  1678. rotation: totalRotation
  1679. });
  1680. if (this.svg) {
  1681. this.cssTransform(this.svg, true);
  1682. this.eventBus.dispatch('pagerendered', {
  1683. source: this,
  1684. pageNumber: this.id,
  1685. cssTransform: true
  1686. });
  1687. return;
  1688. }
  1689. var isScalingRestricted = false;
  1690. if (this.canvas && _pdfjsLib.PDFJS.maxCanvasPixels > 0) {
  1691. var outputScale = this.outputScale;
  1692. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > _pdfjsLib.PDFJS.maxCanvasPixels) {
  1693. isScalingRestricted = true;
  1694. }
  1695. }
  1696. if (this.canvas) {
  1697. if (_pdfjsLib.PDFJS.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  1698. this.cssTransform(this.canvas, true);
  1699. this.eventBus.dispatch('pagerendered', {
  1700. source: this,
  1701. pageNumber: this.id,
  1702. cssTransform: true
  1703. });
  1704. return;
  1705. }
  1706. if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
  1707. this.zoomLayer = this.canvas.parentNode;
  1708. this.zoomLayer.style.position = 'absolute';
  1709. }
  1710. }
  1711. if (this.zoomLayer) {
  1712. this.cssTransform(this.zoomLayer.firstChild);
  1713. }
  1714. this.reset(true, true);
  1715. }
  1716. }, {
  1717. key: 'cancelRendering',
  1718. value: function cancelRendering() {
  1719. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1720. if (this.paintTask) {
  1721. this.paintTask.cancel();
  1722. this.paintTask = null;
  1723. }
  1724. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  1725. this.resume = null;
  1726. if (this.textLayer) {
  1727. this.textLayer.cancel();
  1728. this.textLayer = null;
  1729. }
  1730. if (!keepAnnotations && this.annotationLayer) {
  1731. this.annotationLayer.cancel();
  1732. this.annotationLayer = null;
  1733. }
  1734. }
  1735. }, {
  1736. key: 'cssTransform',
  1737. value: function cssTransform(target) {
  1738. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  1739. var width = this.viewport.width;
  1740. var height = this.viewport.height;
  1741. var div = this.div;
  1742. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';
  1743. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';
  1744. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  1745. var absRotation = Math.abs(relativeRotation);
  1746. var scaleX = 1,
  1747. scaleY = 1;
  1748. if (absRotation === 90 || absRotation === 270) {
  1749. scaleX = height / width;
  1750. scaleY = width / height;
  1751. }
  1752. var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
  1753. _pdfjsLib.CustomStyle.setProp('transform', target, cssTransform);
  1754. if (this.textLayer) {
  1755. var textLayerViewport = this.textLayer.viewport;
  1756. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  1757. var textAbsRotation = Math.abs(textRelativeRotation);
  1758. var scale = width / textLayerViewport.width;
  1759. if (textAbsRotation === 90 || textAbsRotation === 270) {
  1760. scale = width / textLayerViewport.height;
  1761. }
  1762. var textLayerDiv = this.textLayer.textLayerDiv;
  1763. var transX = void 0,
  1764. transY = void 0;
  1765. switch (textAbsRotation) {
  1766. case 0:
  1767. transX = transY = 0;
  1768. break;
  1769. case 90:
  1770. transX = 0;
  1771. transY = '-' + textLayerDiv.style.height;
  1772. break;
  1773. case 180:
  1774. transX = '-' + textLayerDiv.style.width;
  1775. transY = '-' + textLayerDiv.style.height;
  1776. break;
  1777. case 270:
  1778. transX = '-' + textLayerDiv.style.width;
  1779. transY = 0;
  1780. break;
  1781. default:
  1782. console.error('Bad rotation value.');
  1783. break;
  1784. }
  1785. _pdfjsLib.CustomStyle.setProp('transform', textLayerDiv, 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')');
  1786. _pdfjsLib.CustomStyle.setProp('transformOrigin', textLayerDiv, '0% 0%');
  1787. }
  1788. if (redrawAnnotations && this.annotationLayer) {
  1789. this.annotationLayer.render(this.viewport, 'display');
  1790. }
  1791. }
  1792. }, {
  1793. key: 'getPagePoint',
  1794. value: function getPagePoint(x, y) {
  1795. return this.viewport.convertToPdfPoint(x, y);
  1796. }
  1797. }, {
  1798. key: 'draw',
  1799. value: function draw() {
  1800. var _this = this;
  1801. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  1802. console.error('Must be in new state before drawing');
  1803. this.reset();
  1804. }
  1805. if (!this.pdfPage) {
  1806. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  1807. return Promise.reject(new Error('Page is not loaded'));
  1808. }
  1809. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  1810. var pdfPage = this.pdfPage;
  1811. var div = this.div;
  1812. var canvasWrapper = document.createElement('div');
  1813. canvasWrapper.style.width = div.style.width;
  1814. canvasWrapper.style.height = div.style.height;
  1815. canvasWrapper.classList.add('canvasWrapper');
  1816. if (this.annotationLayer && this.annotationLayer.div) {
  1817. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  1818. } else {
  1819. div.appendChild(canvasWrapper);
  1820. }
  1821. var textLayer = null;
  1822. if (this.textLayerFactory) {
  1823. var textLayerDiv = document.createElement('div');
  1824. textLayerDiv.className = 'textLayer';
  1825. textLayerDiv.style.width = canvasWrapper.style.width;
  1826. textLayerDiv.style.height = canvasWrapper.style.height;
  1827. if (this.annotationLayer && this.annotationLayer.div) {
  1828. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  1829. } else {
  1830. div.appendChild(textLayerDiv);
  1831. }
  1832. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.enhanceTextSelection);
  1833. }
  1834. this.textLayer = textLayer;
  1835. var renderContinueCallback = null;
  1836. if (this.renderingQueue) {
  1837. renderContinueCallback = function renderContinueCallback(cont) {
  1838. if (!_this.renderingQueue.isHighestPriority(_this)) {
  1839. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  1840. _this.resume = function () {
  1841. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  1842. cont();
  1843. };
  1844. return;
  1845. }
  1846. cont();
  1847. };
  1848. }
  1849. var finishPaintTask = function finishPaintTask(error) {
  1850. if (paintTask === _this.paintTask) {
  1851. _this.paintTask = null;
  1852. }
  1853. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  1854. _this.error = null;
  1855. return Promise.resolve(undefined);
  1856. }
  1857. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  1858. if (_this.loadingIconDiv) {
  1859. div.removeChild(_this.loadingIconDiv);
  1860. delete _this.loadingIconDiv;
  1861. }
  1862. _this._resetZoomLayer(true);
  1863. _this.error = error;
  1864. _this.stats = pdfPage.stats;
  1865. if (_this.onAfterDraw) {
  1866. _this.onAfterDraw();
  1867. }
  1868. _this.eventBus.dispatch('pagerendered', {
  1869. source: _this,
  1870. pageNumber: _this.id,
  1871. cssTransform: false
  1872. });
  1873. if (error) {
  1874. return Promise.reject(error);
  1875. }
  1876. return Promise.resolve(undefined);
  1877. };
  1878. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  1879. paintTask.onRenderContinue = renderContinueCallback;
  1880. this.paintTask = paintTask;
  1881. var resultPromise = paintTask.promise.then(function () {
  1882. return finishPaintTask(null).then(function () {
  1883. if (textLayer) {
  1884. var readableStream = pdfPage.streamTextContent({ normalizeWhitespace: true });
  1885. textLayer.setTextContentStream(readableStream);
  1886. textLayer.render();
  1887. }
  1888. });
  1889. }, function (reason) {
  1890. return finishPaintTask(reason);
  1891. });
  1892. if (this.annotationLayerFactory) {
  1893. if (!this.annotationLayer) {
  1894. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.renderInteractiveForms, this.l10n);
  1895. }
  1896. this.annotationLayer.render(this.viewport, 'display');
  1897. }
  1898. div.setAttribute('data-loaded', true);
  1899. if (this.onBeforeDraw) {
  1900. this.onBeforeDraw();
  1901. }
  1902. return resultPromise;
  1903. }
  1904. }, {
  1905. key: 'paintOnCanvas',
  1906. value: function paintOnCanvas(canvasWrapper) {
  1907. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  1908. var result = {
  1909. promise: renderCapability.promise,
  1910. onRenderContinue: function onRenderContinue(cont) {
  1911. cont();
  1912. },
  1913. cancel: function cancel() {
  1914. renderTask.cancel();
  1915. }
  1916. };
  1917. var viewport = this.viewport;
  1918. var canvas = document.createElement('canvas');
  1919. canvas.id = this.renderingId;
  1920. canvas.setAttribute('hidden', 'hidden');
  1921. var isCanvasHidden = true;
  1922. var showCanvas = function showCanvas() {
  1923. if (isCanvasHidden) {
  1924. canvas.removeAttribute('hidden');
  1925. isCanvasHidden = false;
  1926. }
  1927. };
  1928. canvasWrapper.appendChild(canvas);
  1929. this.canvas = canvas;
  1930. canvas.mozOpaque = true;
  1931. var ctx = canvas.getContext('2d', { alpha: false });
  1932. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  1933. this.outputScale = outputScale;
  1934. if (_pdfjsLib.PDFJS.useOnlyCssZoom) {
  1935. var actualSizeViewport = viewport.clone({ scale: _ui_utils.CSS_UNITS });
  1936. outputScale.sx *= actualSizeViewport.width / viewport.width;
  1937. outputScale.sy *= actualSizeViewport.height / viewport.height;
  1938. outputScale.scaled = true;
  1939. }
  1940. if (_pdfjsLib.PDFJS.maxCanvasPixels > 0) {
  1941. var pixelsInViewport = viewport.width * viewport.height;
  1942. var maxScale = Math.sqrt(_pdfjsLib.PDFJS.maxCanvasPixels / pixelsInViewport);
  1943. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  1944. outputScale.sx = maxScale;
  1945. outputScale.sy = maxScale;
  1946. outputScale.scaled = true;
  1947. this.hasRestrictedScaling = true;
  1948. } else {
  1949. this.hasRestrictedScaling = false;
  1950. }
  1951. }
  1952. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  1953. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  1954. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  1955. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  1956. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px';
  1957. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px';
  1958. this.paintedViewportMap.set(canvas, viewport);
  1959. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  1960. var renderContext = {
  1961. canvasContext: ctx,
  1962. transform: transform,
  1963. viewport: this.viewport,
  1964. renderInteractiveForms: this.renderInteractiveForms
  1965. };
  1966. var renderTask = this.pdfPage.render(renderContext);
  1967. renderTask.onContinue = function (cont) {
  1968. showCanvas();
  1969. if (result.onRenderContinue) {
  1970. result.onRenderContinue(cont);
  1971. } else {
  1972. cont();
  1973. }
  1974. };
  1975. renderTask.promise.then(function () {
  1976. showCanvas();
  1977. renderCapability.resolve(undefined);
  1978. }, function (error) {
  1979. showCanvas();
  1980. renderCapability.reject(error);
  1981. });
  1982. return result;
  1983. }
  1984. }, {
  1985. key: 'paintOnSvg',
  1986. value: function paintOnSvg(wrapper) {
  1987. var _this2 = this;
  1988. var cancelled = false;
  1989. var ensureNotCancelled = function ensureNotCancelled() {
  1990. if (cancelled) {
  1991. throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');
  1992. }
  1993. };
  1994. var pdfPage = this.pdfPage;
  1995. var actualSizeViewport = this.viewport.clone({ scale: _ui_utils.CSS_UNITS });
  1996. var promise = pdfPage.getOperatorList().then(function (opList) {
  1997. ensureNotCancelled();
  1998. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  1999. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  2000. ensureNotCancelled();
  2001. _this2.svg = svg;
  2002. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  2003. svg.style.width = wrapper.style.width;
  2004. svg.style.height = wrapper.style.height;
  2005. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  2006. wrapper.appendChild(svg);
  2007. });
  2008. });
  2009. return {
  2010. promise: promise,
  2011. onRenderContinue: function onRenderContinue(cont) {
  2012. cont();
  2013. },
  2014. cancel: function cancel() {
  2015. cancelled = true;
  2016. }
  2017. };
  2018. }
  2019. }, {
  2020. key: 'setPageLabel',
  2021. value: function setPageLabel(label) {
  2022. this.pageLabel = typeof label === 'string' ? label : null;
  2023. if (this.pageLabel !== null) {
  2024. this.div.setAttribute('data-page-label', this.pageLabel);
  2025. } else {
  2026. this.div.removeAttribute('data-page-label');
  2027. }
  2028. }
  2029. }, {
  2030. key: 'width',
  2031. get: function get() {
  2032. return this.viewport.width;
  2033. }
  2034. }, {
  2035. key: 'height',
  2036. get: function get() {
  2037. return this.viewport.height;
  2038. }
  2039. }]);
  2040. return PDFPageView;
  2041. }();
  2042. exports.PDFPageView = PDFPageView;
  2043. /***/ }),
  2044. /* 7 */
  2045. /***/ (function(module, exports, __w_pdfjs_require__) {
  2046. "use strict";
  2047. Object.defineProperty(exports, "__esModule", {
  2048. value: true
  2049. });
  2050. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2051. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2052. var CLEANUP_TIMEOUT = 30000;
  2053. var RenderingStates = {
  2054. INITIAL: 0,
  2055. RUNNING: 1,
  2056. PAUSED: 2,
  2057. FINISHED: 3
  2058. };
  2059. var PDFRenderingQueue = function () {
  2060. function PDFRenderingQueue() {
  2061. _classCallCheck(this, PDFRenderingQueue);
  2062. this.pdfViewer = null;
  2063. this.pdfThumbnailViewer = null;
  2064. this.onIdle = null;
  2065. this.highestPriorityPage = null;
  2066. this.idleTimeout = null;
  2067. this.printing = false;
  2068. this.isThumbnailViewEnabled = false;
  2069. }
  2070. _createClass(PDFRenderingQueue, [{
  2071. key: "setViewer",
  2072. value: function setViewer(pdfViewer) {
  2073. this.pdfViewer = pdfViewer;
  2074. }
  2075. }, {
  2076. key: "setThumbnailViewer",
  2077. value: function setThumbnailViewer(pdfThumbnailViewer) {
  2078. this.pdfThumbnailViewer = pdfThumbnailViewer;
  2079. }
  2080. }, {
  2081. key: "isHighestPriority",
  2082. value: function isHighestPriority(view) {
  2083. return this.highestPriorityPage === view.renderingId;
  2084. }
  2085. }, {
  2086. key: "renderHighestPriority",
  2087. value: function renderHighestPriority(currentlyVisiblePages) {
  2088. if (this.idleTimeout) {
  2089. clearTimeout(this.idleTimeout);
  2090. this.idleTimeout = null;
  2091. }
  2092. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  2093. return;
  2094. }
  2095. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  2096. if (this.pdfThumbnailViewer.forceRendering()) {
  2097. return;
  2098. }
  2099. }
  2100. if (this.printing) {
  2101. return;
  2102. }
  2103. if (this.onIdle) {
  2104. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  2105. }
  2106. }
  2107. }, {
  2108. key: "getHighestPriority",
  2109. value: function getHighestPriority(visible, views, scrolledDown) {
  2110. var visibleViews = visible.views;
  2111. var numVisible = visibleViews.length;
  2112. if (numVisible === 0) {
  2113. return false;
  2114. }
  2115. for (var i = 0; i < numVisible; ++i) {
  2116. var view = visibleViews[i].view;
  2117. if (!this.isViewFinished(view)) {
  2118. return view;
  2119. }
  2120. }
  2121. if (scrolledDown) {
  2122. var nextPageIndex = visible.last.id;
  2123. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  2124. return views[nextPageIndex];
  2125. }
  2126. } else {
  2127. var previousPageIndex = visible.first.id - 2;
  2128. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  2129. return views[previousPageIndex];
  2130. }
  2131. }
  2132. return null;
  2133. }
  2134. }, {
  2135. key: "isViewFinished",
  2136. value: function isViewFinished(view) {
  2137. return view.renderingState === RenderingStates.FINISHED;
  2138. }
  2139. }, {
  2140. key: "renderView",
  2141. value: function renderView(view) {
  2142. var _this = this;
  2143. switch (view.renderingState) {
  2144. case RenderingStates.FINISHED:
  2145. return false;
  2146. case RenderingStates.PAUSED:
  2147. this.highestPriorityPage = view.renderingId;
  2148. view.resume();
  2149. break;
  2150. case RenderingStates.RUNNING:
  2151. this.highestPriorityPage = view.renderingId;
  2152. break;
  2153. case RenderingStates.INITIAL:
  2154. this.highestPriorityPage = view.renderingId;
  2155. var continueRendering = function continueRendering() {
  2156. _this.renderHighestPriority();
  2157. };
  2158. view.draw().then(continueRendering, continueRendering);
  2159. break;
  2160. }
  2161. return true;
  2162. }
  2163. }]);
  2164. return PDFRenderingQueue;
  2165. }();
  2166. exports.RenderingStates = RenderingStates;
  2167. exports.PDFRenderingQueue = PDFRenderingQueue;
  2168. /***/ }),
  2169. /* 8 */
  2170. /***/ (function(module, exports, __w_pdfjs_require__) {
  2171. "use strict";
  2172. Object.defineProperty(exports, "__esModule", {
  2173. value: true
  2174. });
  2175. exports.BaseViewer = undefined;
  2176. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2177. var _pdfjsLib = __w_pdfjs_require__(0);
  2178. var _ui_utils = __w_pdfjs_require__(1);
  2179. var _pdf_rendering_queue = __w_pdfjs_require__(7);
  2180. var _annotation_layer_builder = __w_pdfjs_require__(4);
  2181. var _dom_events = __w_pdfjs_require__(2);
  2182. var _pdf_page_view = __w_pdfjs_require__(6);
  2183. var _pdf_link_service = __w_pdfjs_require__(3);
  2184. var _text_layer_builder = __w_pdfjs_require__(5);
  2185. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2186. var DEFAULT_CACHE_SIZE = 10;
  2187. function PDFPageViewBuffer(size) {
  2188. var data = [];
  2189. this.push = function (view) {
  2190. var i = data.indexOf(view);
  2191. if (i >= 0) {
  2192. data.splice(i, 1);
  2193. }
  2194. data.push(view);
  2195. if (data.length > size) {
  2196. data.shift().destroy();
  2197. }
  2198. };
  2199. this.resize = function (newSize) {
  2200. size = newSize;
  2201. while (data.length > size) {
  2202. data.shift().destroy();
  2203. }
  2204. };
  2205. }
  2206. function isSameScale(oldScale, newScale) {
  2207. if (newScale === oldScale) {
  2208. return true;
  2209. }
  2210. if (Math.abs(newScale - oldScale) < 1e-15) {
  2211. return true;
  2212. }
  2213. return false;
  2214. }
  2215. function isPortraitOrientation(size) {
  2216. return size.width <= size.height;
  2217. }
  2218. var BaseViewer = function () {
  2219. function BaseViewer(options) {
  2220. _classCallCheck(this, BaseViewer);
  2221. if (this.constructor === BaseViewer) {
  2222. throw new Error('Cannot initialize BaseViewer.');
  2223. }
  2224. this._name = this.constructor.name;
  2225. this.container = options.container;
  2226. this.viewer = options.viewer || options.container.firstElementChild;
  2227. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  2228. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  2229. this.downloadManager = options.downloadManager || null;
  2230. this.removePageBorders = options.removePageBorders || false;
  2231. this.enhanceTextSelection = options.enhanceTextSelection || false;
  2232. this.renderInteractiveForms = options.renderInteractiveForms || false;
  2233. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  2234. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  2235. this.l10n = options.l10n || _ui_utils.NullL10n;
  2236. this.defaultRenderingQueue = !options.renderingQueue;
  2237. if (this.defaultRenderingQueue) {
  2238. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  2239. this.renderingQueue.setViewer(this);
  2240. } else {
  2241. this.renderingQueue = options.renderingQueue;
  2242. }
  2243. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  2244. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  2245. this._resetView();
  2246. if (this.removePageBorders) {
  2247. this.viewer.classList.add('removePageBorders');
  2248. }
  2249. }
  2250. _createClass(BaseViewer, [{
  2251. key: 'getPageView',
  2252. value: function getPageView(index) {
  2253. return this._pages[index];
  2254. }
  2255. }, {
  2256. key: '_setCurrentPageNumber',
  2257. value: function _setCurrentPageNumber(val) {
  2258. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  2259. if (this._currentPageNumber === val) {
  2260. if (resetCurrentPageView) {
  2261. this._resetCurrentPageView();
  2262. }
  2263. return;
  2264. }
  2265. if (!(0 < val && val <= this.pagesCount)) {
  2266. console.error(this._name + '._setCurrentPageNumber: "' + val + '" is out of bounds.');
  2267. return;
  2268. }
  2269. var arg = {
  2270. source: this,
  2271. pageNumber: val,
  2272. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  2273. };
  2274. this._currentPageNumber = val;
  2275. this.eventBus.dispatch('pagechanging', arg);
  2276. this.eventBus.dispatch('pagechange', arg);
  2277. if (resetCurrentPageView) {
  2278. this._resetCurrentPageView();
  2279. }
  2280. }
  2281. }, {
  2282. key: 'setDocument',
  2283. value: function setDocument(pdfDocument) {
  2284. var _this = this;
  2285. if (this.pdfDocument) {
  2286. this._cancelRendering();
  2287. this._resetView();
  2288. }
  2289. this.pdfDocument = pdfDocument;
  2290. if (!pdfDocument) {
  2291. return;
  2292. }
  2293. var pagesCount = pdfDocument.numPages;
  2294. var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  2295. this.pagesPromise = pagesCapability.promise;
  2296. pagesCapability.promise.then(function () {
  2297. _this._pageViewsReady = true;
  2298. _this.eventBus.dispatch('pagesloaded', {
  2299. source: _this,
  2300. pagesCount: pagesCount
  2301. });
  2302. });
  2303. var isOnePageRenderedResolved = false;
  2304. var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  2305. this.onePageRendered = onePageRenderedCapability.promise;
  2306. var bindOnAfterAndBeforeDraw = function bindOnAfterAndBeforeDraw(pageView) {
  2307. pageView.onBeforeDraw = function () {
  2308. _this._buffer.push(pageView);
  2309. };
  2310. pageView.onAfterDraw = function () {
  2311. if (!isOnePageRenderedResolved) {
  2312. isOnePageRenderedResolved = true;
  2313. onePageRenderedCapability.resolve();
  2314. }
  2315. };
  2316. };
  2317. var firstPagePromise = pdfDocument.getPage(1);
  2318. this.firstPagePromise = firstPagePromise;
  2319. firstPagePromise.then(function (pdfPage) {
  2320. var scale = _this.currentScale;
  2321. var viewport = pdfPage.getViewport(scale * _ui_utils.CSS_UNITS);
  2322. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  2323. var textLayerFactory = null;
  2324. if (!_pdfjsLib.PDFJS.disableTextLayer) {
  2325. textLayerFactory = _this;
  2326. }
  2327. var pageView = new _pdf_page_view.PDFPageView({
  2328. container: _this._setDocumentViewerElement,
  2329. eventBus: _this.eventBus,
  2330. id: pageNum,
  2331. scale: scale,
  2332. defaultViewport: viewport.clone(),
  2333. renderingQueue: _this.renderingQueue,
  2334. textLayerFactory: textLayerFactory,
  2335. annotationLayerFactory: _this,
  2336. enhanceTextSelection: _this.enhanceTextSelection,
  2337. renderInteractiveForms: _this.renderInteractiveForms,
  2338. renderer: _this.renderer,
  2339. l10n: _this.l10n
  2340. });
  2341. bindOnAfterAndBeforeDraw(pageView);
  2342. _this._pages.push(pageView);
  2343. }
  2344. onePageRenderedCapability.promise.then(function () {
  2345. if (_pdfjsLib.PDFJS.disableAutoFetch) {
  2346. pagesCapability.resolve();
  2347. return;
  2348. }
  2349. var getPagesLeft = pagesCount;
  2350. var _loop = function _loop(_pageNum) {
  2351. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  2352. var pageView = _this._pages[_pageNum - 1];
  2353. if (!pageView.pdfPage) {
  2354. pageView.setPdfPage(pdfPage);
  2355. }
  2356. _this.linkService.cachePageRef(_pageNum, pdfPage.ref);
  2357. if (--getPagesLeft === 0) {
  2358. pagesCapability.resolve();
  2359. }
  2360. }, function (reason) {
  2361. console.error('Unable to get page ' + _pageNum + ' to initialize viewer', reason);
  2362. if (--getPagesLeft === 0) {
  2363. pagesCapability.resolve();
  2364. }
  2365. });
  2366. };
  2367. for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {
  2368. _loop(_pageNum);
  2369. }
  2370. });
  2371. _this.eventBus.dispatch('pagesinit', { source: _this });
  2372. if (_this.defaultRenderingQueue) {
  2373. _this.update();
  2374. }
  2375. if (_this.findController) {
  2376. _this.findController.resolveFirstPage();
  2377. }
  2378. }).catch(function (reason) {
  2379. console.error('Unable to initialize viewer', reason);
  2380. });
  2381. }
  2382. }, {
  2383. key: 'setPageLabels',
  2384. value: function setPageLabels(labels) {
  2385. if (!this.pdfDocument) {
  2386. return;
  2387. }
  2388. if (!labels) {
  2389. this._pageLabels = null;
  2390. } else if (!(labels instanceof Array && this.pdfDocument.numPages === labels.length)) {
  2391. this._pageLabels = null;
  2392. console.error(this._name + '.setPageLabels: Invalid page labels.');
  2393. } else {
  2394. this._pageLabels = labels;
  2395. }
  2396. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  2397. var pageView = this._pages[i];
  2398. var label = this._pageLabels && this._pageLabels[i];
  2399. pageView.setPageLabel(label);
  2400. }
  2401. }
  2402. }, {
  2403. key: '_resetView',
  2404. value: function _resetView() {
  2405. this._pages = [];
  2406. this._currentPageNumber = 1;
  2407. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  2408. this._currentScaleValue = null;
  2409. this._pageLabels = null;
  2410. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  2411. this._location = null;
  2412. this._pagesRotation = 0;
  2413. this._pagesRequests = [];
  2414. this._pageViewsReady = false;
  2415. this.viewer.textContent = '';
  2416. }
  2417. }, {
  2418. key: '_scrollUpdate',
  2419. value: function _scrollUpdate() {
  2420. if (this.pagesCount === 0) {
  2421. return;
  2422. }
  2423. this.update();
  2424. }
  2425. }, {
  2426. key: '_scrollIntoView',
  2427. value: function _scrollIntoView(_ref) {
  2428. var pageDiv = _ref.pageDiv,
  2429. _ref$pageSpot = _ref.pageSpot,
  2430. pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot,
  2431. _ref$pageNumber = _ref.pageNumber,
  2432. pageNumber = _ref$pageNumber === undefined ? null : _ref$pageNumber;
  2433. throw new Error('Not implemented: _scrollIntoView');
  2434. }
  2435. }, {
  2436. key: '_setScaleDispatchEvent',
  2437. value: function _setScaleDispatchEvent(newScale, newValue) {
  2438. var preset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  2439. var arg = {
  2440. source: this,
  2441. scale: newScale,
  2442. presetValue: preset ? newValue : undefined
  2443. };
  2444. this.eventBus.dispatch('scalechanging', arg);
  2445. this.eventBus.dispatch('scalechange', arg);
  2446. }
  2447. }, {
  2448. key: '_setScaleUpdatePages',
  2449. value: function _setScaleUpdatePages(newScale, newValue) {
  2450. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  2451. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  2452. this._currentScaleValue = newValue.toString();
  2453. if (isSameScale(this._currentScale, newScale)) {
  2454. if (preset) {
  2455. this._setScaleDispatchEvent(newScale, newValue, true);
  2456. }
  2457. return;
  2458. }
  2459. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  2460. this._pages[i].update(newScale);
  2461. }
  2462. this._currentScale = newScale;
  2463. if (!noScroll) {
  2464. var page = this._currentPageNumber,
  2465. dest = void 0;
  2466. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  2467. page = this._location.pageNumber;
  2468. dest = [null, { name: 'XYZ' }, this._location.left, this._location.top, null];
  2469. }
  2470. this.scrollPageIntoView({
  2471. pageNumber: page,
  2472. destArray: dest,
  2473. allowNegativeOffset: true
  2474. });
  2475. }
  2476. this._setScaleDispatchEvent(newScale, newValue, preset);
  2477. if (this.defaultRenderingQueue) {
  2478. this.update();
  2479. }
  2480. }
  2481. }, {
  2482. key: '_setScale',
  2483. value: function _setScale(value) {
  2484. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  2485. var scale = parseFloat(value);
  2486. if (scale > 0) {
  2487. this._setScaleUpdatePages(scale, value, noScroll, false);
  2488. } else {
  2489. var currentPage = this._pages[this._currentPageNumber - 1];
  2490. if (!currentPage) {
  2491. return;
  2492. }
  2493. var hPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  2494. var vPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  2495. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  2496. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  2497. switch (value) {
  2498. case 'page-actual':
  2499. scale = 1;
  2500. break;
  2501. case 'page-width':
  2502. scale = pageWidthScale;
  2503. break;
  2504. case 'page-height':
  2505. scale = pageHeightScale;
  2506. break;
  2507. case 'page-fit':
  2508. scale = Math.min(pageWidthScale, pageHeightScale);
  2509. break;
  2510. case 'auto':
  2511. var isLandscape = currentPage.width > currentPage.height;
  2512. var horizontalScale = isLandscape ? Math.min(pageHeightScale, pageWidthScale) : pageWidthScale;
  2513. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  2514. break;
  2515. default:
  2516. console.error(this._name + '._setScale: "' + value + '" is an unknown zoom value.');
  2517. return;
  2518. }
  2519. this._setScaleUpdatePages(scale, value, noScroll, true);
  2520. }
  2521. }
  2522. }, {
  2523. key: '_resetCurrentPageView',
  2524. value: function _resetCurrentPageView() {
  2525. if (this.isInPresentationMode) {
  2526. this._setScale(this._currentScaleValue, true);
  2527. }
  2528. var pageView = this._pages[this._currentPageNumber - 1];
  2529. this._scrollIntoView({ pageDiv: pageView.div });
  2530. }
  2531. }, {
  2532. key: 'scrollPageIntoView',
  2533. value: function scrollPageIntoView(params) {
  2534. if (!this.pdfDocument) {
  2535. return;
  2536. }
  2537. var pageNumber = params.pageNumber || 0;
  2538. var dest = params.destArray || null;
  2539. var allowNegativeOffset = params.allowNegativeOffset || false;
  2540. if (this.isInPresentationMode || !dest) {
  2541. this._setCurrentPageNumber(pageNumber, true);
  2542. return;
  2543. }
  2544. var pageView = this._pages[pageNumber - 1];
  2545. if (!pageView) {
  2546. console.error(this._name + '.scrollPageIntoView: Invalid "pageNumber" parameter.');
  2547. return;
  2548. }
  2549. var x = 0,
  2550. y = 0;
  2551. var width = 0,
  2552. height = 0,
  2553. widthScale = void 0,
  2554. heightScale = void 0;
  2555. var changeOrientation = pageView.rotation % 180 === 0 ? false : true;
  2556. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  2557. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  2558. var scale = 0;
  2559. switch (dest[1].name) {
  2560. case 'XYZ':
  2561. x = dest[2];
  2562. y = dest[3];
  2563. scale = dest[4];
  2564. x = x !== null ? x : 0;
  2565. y = y !== null ? y : pageHeight;
  2566. break;
  2567. case 'Fit':
  2568. case 'FitB':
  2569. scale = 'page-fit';
  2570. break;
  2571. case 'FitH':
  2572. case 'FitBH':
  2573. y = dest[2];
  2574. scale = 'page-width';
  2575. if (y === null && this._location) {
  2576. x = this._location.left;
  2577. y = this._location.top;
  2578. }
  2579. break;
  2580. case 'FitV':
  2581. case 'FitBV':
  2582. x = dest[2];
  2583. width = pageWidth;
  2584. height = pageHeight;
  2585. scale = 'page-height';
  2586. break;
  2587. case 'FitR':
  2588. x = dest[2];
  2589. y = dest[3];
  2590. width = dest[4] - x;
  2591. height = dest[5] - y;
  2592. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  2593. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  2594. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  2595. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  2596. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  2597. break;
  2598. default:
  2599. console.error(this._name + '.scrollPageIntoView: "' + dest[1].name + '" ' + 'is not a valid destination type.');
  2600. return;
  2601. }
  2602. if (scale && scale !== this._currentScale) {
  2603. this.currentScaleValue = scale;
  2604. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  2605. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  2606. }
  2607. if (scale === 'page-fit' && !dest[4]) {
  2608. this._scrollIntoView({
  2609. pageDiv: pageView.div,
  2610. pageNumber: pageNumber
  2611. });
  2612. return;
  2613. }
  2614. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  2615. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  2616. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  2617. if (!allowNegativeOffset) {
  2618. left = Math.max(left, 0);
  2619. top = Math.max(top, 0);
  2620. }
  2621. this._scrollIntoView({
  2622. pageDiv: pageView.div,
  2623. pageSpot: {
  2624. left: left,
  2625. top: top
  2626. },
  2627. pageNumber: pageNumber
  2628. });
  2629. }
  2630. }, {
  2631. key: '_resizeBuffer',
  2632. value: function _resizeBuffer(numVisiblePages) {
  2633. var suggestedCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  2634. this._buffer.resize(suggestedCacheSize);
  2635. }
  2636. }, {
  2637. key: '_updateLocation',
  2638. value: function _updateLocation(firstPage) {
  2639. var currentScale = this._currentScale;
  2640. var currentScaleValue = this._currentScaleValue;
  2641. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  2642. var pageNumber = firstPage.id;
  2643. var pdfOpenParams = '#page=' + pageNumber;
  2644. pdfOpenParams += '&zoom=' + normalizedScaleValue;
  2645. var currentPageView = this._pages[pageNumber - 1];
  2646. var container = this.container;
  2647. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  2648. var intLeft = Math.round(topLeft[0]);
  2649. var intTop = Math.round(topLeft[1]);
  2650. pdfOpenParams += ',' + intLeft + ',' + intTop;
  2651. this._location = {
  2652. pageNumber: pageNumber,
  2653. scale: normalizedScaleValue,
  2654. top: intTop,
  2655. left: intLeft,
  2656. rotation: this._pagesRotation,
  2657. pdfOpenParams: pdfOpenParams
  2658. };
  2659. }
  2660. }, {
  2661. key: 'update',
  2662. value: function update() {
  2663. throw new Error('Not implemented: update');
  2664. }
  2665. }, {
  2666. key: 'containsElement',
  2667. value: function containsElement(element) {
  2668. return this.container.contains(element);
  2669. }
  2670. }, {
  2671. key: 'focus',
  2672. value: function focus() {
  2673. this.container.focus();
  2674. }
  2675. }, {
  2676. key: '_getVisiblePages',
  2677. value: function _getVisiblePages() {
  2678. throw new Error('Not implemented: _getVisiblePages');
  2679. }
  2680. }, {
  2681. key: 'cleanup',
  2682. value: function cleanup() {
  2683. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  2684. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  2685. this._pages[i].reset();
  2686. }
  2687. }
  2688. }
  2689. }, {
  2690. key: '_cancelRendering',
  2691. value: function _cancelRendering() {
  2692. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  2693. if (this._pages[i]) {
  2694. this._pages[i].cancelRendering();
  2695. }
  2696. }
  2697. }
  2698. }, {
  2699. key: '_ensurePdfPageLoaded',
  2700. value: function _ensurePdfPageLoaded(pageView) {
  2701. var _this2 = this;
  2702. if (pageView.pdfPage) {
  2703. return Promise.resolve(pageView.pdfPage);
  2704. }
  2705. var pageNumber = pageView.id;
  2706. if (this._pagesRequests[pageNumber]) {
  2707. return this._pagesRequests[pageNumber];
  2708. }
  2709. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  2710. if (!pageView.pdfPage) {
  2711. pageView.setPdfPage(pdfPage);
  2712. }
  2713. _this2._pagesRequests[pageNumber] = null;
  2714. return pdfPage;
  2715. }).catch(function (reason) {
  2716. console.error('Unable to get page for page view', reason);
  2717. _this2._pagesRequests[pageNumber] = null;
  2718. });
  2719. this._pagesRequests[pageNumber] = promise;
  2720. return promise;
  2721. }
  2722. }, {
  2723. key: 'forceRendering',
  2724. value: function forceRendering(currentlyVisiblePages) {
  2725. var _this3 = this;
  2726. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  2727. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, this.scroll.down);
  2728. if (pageView) {
  2729. this._ensurePdfPageLoaded(pageView).then(function () {
  2730. _this3.renderingQueue.renderView(pageView);
  2731. });
  2732. return true;
  2733. }
  2734. return false;
  2735. }
  2736. }, {
  2737. key: 'getPageTextContent',
  2738. value: function getPageTextContent(pageIndex) {
  2739. return this.pdfDocument.getPage(pageIndex + 1).then(function (page) {
  2740. return page.getTextContent({ normalizeWhitespace: true });
  2741. });
  2742. }
  2743. }, {
  2744. key: 'createTextLayerBuilder',
  2745. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  2746. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  2747. return new _text_layer_builder.TextLayerBuilder({
  2748. textLayerDiv: textLayerDiv,
  2749. eventBus: this.eventBus,
  2750. pageIndex: pageIndex,
  2751. viewport: viewport,
  2752. findController: this.isInPresentationMode ? null : this.findController,
  2753. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  2754. });
  2755. }
  2756. }, {
  2757. key: 'createAnnotationLayerBuilder',
  2758. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  2759. var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  2760. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  2761. return new _annotation_layer_builder.AnnotationLayerBuilder({
  2762. pageDiv: pageDiv,
  2763. pdfPage: pdfPage,
  2764. renderInteractiveForms: renderInteractiveForms,
  2765. linkService: this.linkService,
  2766. downloadManager: this.downloadManager,
  2767. l10n: l10n
  2768. });
  2769. }
  2770. }, {
  2771. key: 'setFindController',
  2772. value: function setFindController(findController) {
  2773. this.findController = findController;
  2774. }
  2775. }, {
  2776. key: 'getPagesOverview',
  2777. value: function getPagesOverview() {
  2778. var pagesOverview = this._pages.map(function (pageView) {
  2779. var viewport = pageView.pdfPage.getViewport(1);
  2780. return {
  2781. width: viewport.width,
  2782. height: viewport.height,
  2783. rotation: viewport.rotation
  2784. };
  2785. });
  2786. if (!this.enablePrintAutoRotate) {
  2787. return pagesOverview;
  2788. }
  2789. var isFirstPagePortrait = isPortraitOrientation(pagesOverview[0]);
  2790. return pagesOverview.map(function (size) {
  2791. if (isFirstPagePortrait === isPortraitOrientation(size)) {
  2792. return size;
  2793. }
  2794. return {
  2795. width: size.height,
  2796. height: size.width,
  2797. rotation: (size.rotation + 90) % 360
  2798. };
  2799. });
  2800. }
  2801. }, {
  2802. key: 'pagesCount',
  2803. get: function get() {
  2804. return this._pages.length;
  2805. }
  2806. }, {
  2807. key: 'pageViewsReady',
  2808. get: function get() {
  2809. return this._pageViewsReady;
  2810. }
  2811. }, {
  2812. key: 'currentPageNumber',
  2813. get: function get() {
  2814. return this._currentPageNumber;
  2815. },
  2816. set: function set(val) {
  2817. if (!Number.isInteger(val)) {
  2818. throw new Error('Invalid page number.');
  2819. }
  2820. if (!this.pdfDocument) {
  2821. return;
  2822. }
  2823. this._setCurrentPageNumber(val, true);
  2824. }
  2825. }, {
  2826. key: 'currentPageLabel',
  2827. get: function get() {
  2828. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  2829. },
  2830. set: function set(val) {
  2831. var pageNumber = val | 0;
  2832. if (this._pageLabels) {
  2833. var i = this._pageLabels.indexOf(val);
  2834. if (i >= 0) {
  2835. pageNumber = i + 1;
  2836. }
  2837. }
  2838. this.currentPageNumber = pageNumber;
  2839. }
  2840. }, {
  2841. key: 'currentScale',
  2842. get: function get() {
  2843. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  2844. },
  2845. set: function set(val) {
  2846. if (isNaN(val)) {
  2847. throw new Error('Invalid numeric scale');
  2848. }
  2849. if (!this.pdfDocument) {
  2850. return;
  2851. }
  2852. this._setScale(val, false);
  2853. }
  2854. }, {
  2855. key: 'currentScaleValue',
  2856. get: function get() {
  2857. return this._currentScaleValue;
  2858. },
  2859. set: function set(val) {
  2860. if (!this.pdfDocument) {
  2861. return;
  2862. }
  2863. this._setScale(val, false);
  2864. }
  2865. }, {
  2866. key: 'pagesRotation',
  2867. get: function get() {
  2868. return this._pagesRotation;
  2869. },
  2870. set: function set(rotation) {
  2871. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  2872. throw new Error('Invalid pages rotation angle.');
  2873. }
  2874. if (!this.pdfDocument) {
  2875. return;
  2876. }
  2877. if (this._pagesRotation === rotation) {
  2878. return;
  2879. }
  2880. this._pagesRotation = rotation;
  2881. var pageNumber = this._currentPageNumber;
  2882. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  2883. var pageView = this._pages[i];
  2884. pageView.update(pageView.scale, rotation);
  2885. }
  2886. if (this._currentScaleValue) {
  2887. this._setScale(this._currentScaleValue, true);
  2888. }
  2889. this.eventBus.dispatch('rotationchanging', {
  2890. source: this,
  2891. pagesRotation: rotation,
  2892. pageNumber: pageNumber
  2893. });
  2894. if (this.defaultRenderingQueue) {
  2895. this.update();
  2896. }
  2897. }
  2898. }, {
  2899. key: '_setDocumentViewerElement',
  2900. get: function get() {
  2901. throw new Error('Not implemented: _setDocumentViewerElement');
  2902. }
  2903. }, {
  2904. key: 'isInPresentationMode',
  2905. get: function get() {
  2906. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  2907. }
  2908. }, {
  2909. key: 'isChangingPresentationMode',
  2910. get: function get() {
  2911. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  2912. }
  2913. }, {
  2914. key: 'isHorizontalScrollbarEnabled',
  2915. get: function get() {
  2916. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  2917. }
  2918. }, {
  2919. key: 'hasEqualPageSizes',
  2920. get: function get() {
  2921. var firstPageView = this._pages[0];
  2922. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  2923. var pageView = this._pages[i];
  2924. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  2925. return false;
  2926. }
  2927. }
  2928. return true;
  2929. }
  2930. }]);
  2931. return BaseViewer;
  2932. }();
  2933. exports.BaseViewer = BaseViewer;
  2934. /***/ }),
  2935. /* 9 */
  2936. /***/ (function(module, exports, __w_pdfjs_require__) {
  2937. "use strict";
  2938. Object.defineProperty(exports, "__esModule", {
  2939. value: true
  2940. });
  2941. exports.PDFJS = undefined;
  2942. var _annotation_layer_builder = __w_pdfjs_require__(4);
  2943. var _text_layer_builder = __w_pdfjs_require__(5);
  2944. var _ui_utils = __w_pdfjs_require__(1);
  2945. var _pdf_link_service = __w_pdfjs_require__(3);
  2946. var _download_manager = __w_pdfjs_require__(10);
  2947. var _genericl10n = __w_pdfjs_require__(11);
  2948. var _pdf_find_controller = __w_pdfjs_require__(13);
  2949. var _pdf_history = __w_pdfjs_require__(14);
  2950. var _pdfjs = __w_pdfjs_require__(0);
  2951. var _pdfjs2 = _interopRequireDefault(_pdfjs);
  2952. var _pdf_page_view = __w_pdfjs_require__(6);
  2953. var _pdf_single_page_viewer = __w_pdfjs_require__(15);
  2954. var _pdf_viewer = __w_pdfjs_require__(16);
  2955. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2956. var PDFJS = _pdfjs2.default.PDFJS;
  2957. PDFJS.PDFViewer = _pdf_viewer.PDFViewer;
  2958. PDFJS.PDFSinglePageViewer = _pdf_single_page_viewer.PDFSinglePageViewer;
  2959. PDFJS.PDFPageView = _pdf_page_view.PDFPageView;
  2960. PDFJS.PDFLinkService = _pdf_link_service.PDFLinkService;
  2961. PDFJS.SimpleLinkService = _pdf_link_service.SimpleLinkService;
  2962. PDFJS.TextLayerBuilder = _text_layer_builder.TextLayerBuilder;
  2963. PDFJS.DefaultTextLayerFactory = _text_layer_builder.DefaultTextLayerFactory;
  2964. PDFJS.AnnotationLayerBuilder = _annotation_layer_builder.AnnotationLayerBuilder;
  2965. PDFJS.DefaultAnnotationLayerFactory = _annotation_layer_builder.DefaultAnnotationLayerFactory;
  2966. PDFJS.PDFHistory = _pdf_history.PDFHistory;
  2967. PDFJS.PDFFindController = _pdf_find_controller.PDFFindController;
  2968. PDFJS.EventBus = _ui_utils.EventBus;
  2969. PDFJS.DownloadManager = _download_manager.DownloadManager;
  2970. PDFJS.ProgressBar = _ui_utils.ProgressBar;
  2971. PDFJS.GenericL10n = _genericl10n.GenericL10n;
  2972. PDFJS.NullL10n = _ui_utils.NullL10n;
  2973. exports.PDFJS = PDFJS;
  2974. /***/ }),
  2975. /* 10 */
  2976. /***/ (function(module, exports, __w_pdfjs_require__) {
  2977. "use strict";
  2978. Object.defineProperty(exports, "__esModule", {
  2979. value: true
  2980. });
  2981. exports.DownloadManager = undefined;
  2982. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2983. var _pdfjsLib = __w_pdfjs_require__(0);
  2984. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2985. ;
  2986. function _download(blobUrl, filename) {
  2987. var a = document.createElement('a');
  2988. if (a.click) {
  2989. a.href = blobUrl;
  2990. a.target = '_parent';
  2991. if ('download' in a) {
  2992. a.download = filename;
  2993. }
  2994. (document.body || document.documentElement).appendChild(a);
  2995. a.click();
  2996. a.parentNode.removeChild(a);
  2997. } else {
  2998. if (window.top === window && blobUrl.split('#')[0] === window.location.href.split('#')[0]) {
  2999. var padCharacter = blobUrl.indexOf('?') === -1 ? '?' : '&';
  3000. blobUrl = blobUrl.replace(/#|$/, padCharacter + '$&');
  3001. }
  3002. window.open(blobUrl, '_parent');
  3003. }
  3004. }
  3005. var DownloadManager = function () {
  3006. function DownloadManager() {
  3007. _classCallCheck(this, DownloadManager);
  3008. }
  3009. _createClass(DownloadManager, [{
  3010. key: 'downloadUrl',
  3011. value: function downloadUrl(url, filename) {
  3012. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
  3013. return;
  3014. }
  3015. _download(url + '#pdfjs.action=download', filename);
  3016. }
  3017. }, {
  3018. key: 'downloadData',
  3019. value: function downloadData(data, filename, contentType) {
  3020. if (navigator.msSaveBlob) {
  3021. return navigator.msSaveBlob(new Blob([data], { type: contentType }), filename);
  3022. }
  3023. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, _pdfjsLib.PDFJS.disableCreateObjectURL);
  3024. _download(blobUrl, filename);
  3025. }
  3026. }, {
  3027. key: 'download',
  3028. value: function download(blob, url, filename) {
  3029. if (navigator.msSaveBlob) {
  3030. if (!navigator.msSaveBlob(blob, filename)) {
  3031. this.downloadUrl(url, filename);
  3032. }
  3033. return;
  3034. }
  3035. if (_pdfjsLib.PDFJS.disableCreateObjectURL) {
  3036. this.downloadUrl(url, filename);
  3037. return;
  3038. }
  3039. var blobUrl = URL.createObjectURL(blob);
  3040. _download(blobUrl, filename);
  3041. }
  3042. }]);
  3043. return DownloadManager;
  3044. }();
  3045. exports.DownloadManager = DownloadManager;
  3046. /***/ }),
  3047. /* 11 */
  3048. /***/ (function(module, exports, __w_pdfjs_require__) {
  3049. "use strict";
  3050. Object.defineProperty(exports, "__esModule", {
  3051. value: true
  3052. });
  3053. exports.GenericL10n = undefined;
  3054. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3055. __w_pdfjs_require__(12);
  3056. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3057. var webL10n = document.webL10n;
  3058. var GenericL10n = function () {
  3059. function GenericL10n(lang) {
  3060. _classCallCheck(this, GenericL10n);
  3061. this._lang = lang;
  3062. this._ready = new Promise(function (resolve, reject) {
  3063. webL10n.setLanguage(lang, function () {
  3064. resolve(webL10n);
  3065. });
  3066. });
  3067. }
  3068. _createClass(GenericL10n, [{
  3069. key: 'getDirection',
  3070. value: function getDirection() {
  3071. return this._ready.then(function (l10n) {
  3072. return l10n.getDirection();
  3073. });
  3074. }
  3075. }, {
  3076. key: 'get',
  3077. value: function get(property, args, fallback) {
  3078. return this._ready.then(function (l10n) {
  3079. return l10n.get(property, args, fallback);
  3080. });
  3081. }
  3082. }, {
  3083. key: 'translate',
  3084. value: function translate(element) {
  3085. return this._ready.then(function (l10n) {
  3086. return l10n.translate(element);
  3087. });
  3088. }
  3089. }]);
  3090. return GenericL10n;
  3091. }();
  3092. exports.GenericL10n = GenericL10n;
  3093. /***/ }),
  3094. /* 12 */
  3095. /***/ (function(module, exports, __w_pdfjs_require__) {
  3096. "use strict";
  3097. document.webL10n = function (window, document, undefined) {
  3098. var gL10nData = {};
  3099. var gTextData = '';
  3100. var gTextProp = 'textContent';
  3101. var gLanguage = '';
  3102. var gMacros = {};
  3103. var gReadyState = 'loading';
  3104. var gAsyncResourceLoading = true;
  3105. function getL10nResourceLinks() {
  3106. return document.querySelectorAll('link[type="application/l10n"]');
  3107. }
  3108. function getL10nDictionary() {
  3109. var script = document.querySelector('script[type="application/l10n"]');
  3110. return script ? JSON.parse(script.innerHTML) : null;
  3111. }
  3112. function getTranslatableChildren(element) {
  3113. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  3114. }
  3115. function getL10nAttributes(element) {
  3116. if (!element) return {};
  3117. var l10nId = element.getAttribute('data-l10n-id');
  3118. var l10nArgs = element.getAttribute('data-l10n-args');
  3119. var args = {};
  3120. if (l10nArgs) {
  3121. try {
  3122. args = JSON.parse(l10nArgs);
  3123. } catch (e) {
  3124. console.warn('could not parse arguments for #' + l10nId);
  3125. }
  3126. }
  3127. return {
  3128. id: l10nId,
  3129. args: args
  3130. };
  3131. }
  3132. function fireL10nReadyEvent(lang) {
  3133. var evtObject = document.createEvent('Event');
  3134. evtObject.initEvent('localized', true, false);
  3135. evtObject.language = lang;
  3136. document.dispatchEvent(evtObject);
  3137. }
  3138. function xhrLoadText(url, onSuccess, onFailure) {
  3139. onSuccess = onSuccess || function _onSuccess(data) {};
  3140. onFailure = onFailure || function _onFailure() {};
  3141. var xhr = new XMLHttpRequest();
  3142. xhr.open('GET', url, gAsyncResourceLoading);
  3143. if (xhr.overrideMimeType) {
  3144. xhr.overrideMimeType('text/plain; charset=utf-8');
  3145. }
  3146. xhr.onreadystatechange = function () {
  3147. if (xhr.readyState == 4) {
  3148. if (xhr.status == 200 || xhr.status === 0) {
  3149. onSuccess(xhr.responseText);
  3150. } else {
  3151. onFailure();
  3152. }
  3153. }
  3154. };
  3155. xhr.onerror = onFailure;
  3156. xhr.ontimeout = onFailure;
  3157. try {
  3158. xhr.send(null);
  3159. } catch (e) {
  3160. onFailure();
  3161. }
  3162. }
  3163. function parseResource(href, lang, successCallback, failureCallback) {
  3164. var baseURL = href.replace(/[^\/]*$/, '') || './';
  3165. function evalString(text) {
  3166. if (text.lastIndexOf('\\') < 0) return text;
  3167. return text.replace(/\\\\/g, '\\').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(/\\t/g, '\t').replace(/\\b/g, '\b').replace(/\\f/g, '\f').replace(/\\{/g, '{').replace(/\\}/g, '}').replace(/\\"/g, '"').replace(/\\'/g, "'");
  3168. }
  3169. function parseProperties(text, parsedPropertiesCallback) {
  3170. var dictionary = {};
  3171. var reBlank = /^\s*|\s*$/;
  3172. var reComment = /^\s*#|^\s*$/;
  3173. var reSection = /^\s*\[(.*)\]\s*$/;
  3174. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  3175. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  3176. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  3177. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  3178. var currentLang = '*';
  3179. var genericLang = lang.split('-', 1)[0];
  3180. var skipLang = false;
  3181. var match = '';
  3182. function nextEntry() {
  3183. while (true) {
  3184. if (!entries.length) {
  3185. parsedRawLinesCallback();
  3186. return;
  3187. }
  3188. var line = entries.shift();
  3189. if (reComment.test(line)) continue;
  3190. if (extendedSyntax) {
  3191. match = reSection.exec(line);
  3192. if (match) {
  3193. currentLang = match[1].toLowerCase();
  3194. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  3195. continue;
  3196. } else if (skipLang) {
  3197. continue;
  3198. }
  3199. match = reImport.exec(line);
  3200. if (match) {
  3201. loadImport(baseURL + match[1], nextEntry);
  3202. return;
  3203. }
  3204. }
  3205. var tmp = line.match(reSplit);
  3206. if (tmp && tmp.length == 3) {
  3207. dictionary[tmp[1]] = evalString(tmp[2]);
  3208. }
  3209. }
  3210. }
  3211. nextEntry();
  3212. }
  3213. function loadImport(url, callback) {
  3214. xhrLoadText(url, function (content) {
  3215. parseRawLines(content, false, callback);
  3216. }, function () {
  3217. console.warn(url + ' not found.');
  3218. callback();
  3219. });
  3220. }
  3221. parseRawLines(text, true, function () {
  3222. parsedPropertiesCallback(dictionary);
  3223. });
  3224. }
  3225. xhrLoadText(href, function (response) {
  3226. gTextData += response;
  3227. parseProperties(response, function (data) {
  3228. for (var key in data) {
  3229. var id,
  3230. prop,
  3231. index = key.lastIndexOf('.');
  3232. if (index > 0) {
  3233. id = key.substring(0, index);
  3234. prop = key.substr(index + 1);
  3235. } else {
  3236. id = key;
  3237. prop = gTextProp;
  3238. }
  3239. if (!gL10nData[id]) {
  3240. gL10nData[id] = {};
  3241. }
  3242. gL10nData[id][prop] = data[key];
  3243. }
  3244. if (successCallback) {
  3245. successCallback();
  3246. }
  3247. });
  3248. }, failureCallback);
  3249. }
  3250. function loadLocale(lang, callback) {
  3251. if (lang) {
  3252. lang = lang.toLowerCase();
  3253. }
  3254. callback = callback || function _callback() {};
  3255. clear();
  3256. gLanguage = lang;
  3257. var langLinks = getL10nResourceLinks();
  3258. var langCount = langLinks.length;
  3259. if (langCount === 0) {
  3260. var dict = getL10nDictionary();
  3261. if (dict && dict.locales && dict.default_locale) {
  3262. console.log('using the embedded JSON directory, early way out');
  3263. gL10nData = dict.locales[lang];
  3264. if (!gL10nData) {
  3265. var defaultLocale = dict.default_locale.toLowerCase();
  3266. for (var anyCaseLang in dict.locales) {
  3267. anyCaseLang = anyCaseLang.toLowerCase();
  3268. if (anyCaseLang === lang) {
  3269. gL10nData = dict.locales[lang];
  3270. break;
  3271. } else if (anyCaseLang === defaultLocale) {
  3272. gL10nData = dict.locales[defaultLocale];
  3273. }
  3274. }
  3275. }
  3276. callback();
  3277. } else {
  3278. console.log('no resource to load, early way out');
  3279. }
  3280. fireL10nReadyEvent(lang);
  3281. gReadyState = 'complete';
  3282. return;
  3283. }
  3284. var onResourceLoaded = null;
  3285. var gResourceCount = 0;
  3286. onResourceLoaded = function onResourceLoaded() {
  3287. gResourceCount++;
  3288. if (gResourceCount >= langCount) {
  3289. callback();
  3290. fireL10nReadyEvent(lang);
  3291. gReadyState = 'complete';
  3292. }
  3293. };
  3294. function L10nResourceLink(link) {
  3295. var href = link.href;
  3296. this.load = function (lang, callback) {
  3297. parseResource(href, lang, callback, function () {
  3298. console.warn(href + ' not found.');
  3299. console.warn('"' + lang + '" resource not found');
  3300. gLanguage = '';
  3301. callback();
  3302. });
  3303. };
  3304. }
  3305. for (var i = 0; i < langCount; i++) {
  3306. var resource = new L10nResourceLink(langLinks[i]);
  3307. resource.load(lang, onResourceLoaded);
  3308. }
  3309. }
  3310. function clear() {
  3311. gL10nData = {};
  3312. gTextData = '';
  3313. gLanguage = '';
  3314. }
  3315. function getPluralRules(lang) {
  3316. var locales2rules = {
  3317. 'af': 3,
  3318. 'ak': 4,
  3319. 'am': 4,
  3320. 'ar': 1,
  3321. 'asa': 3,
  3322. 'az': 0,
  3323. 'be': 11,
  3324. 'bem': 3,
  3325. 'bez': 3,
  3326. 'bg': 3,
  3327. 'bh': 4,
  3328. 'bm': 0,
  3329. 'bn': 3,
  3330. 'bo': 0,
  3331. 'br': 20,
  3332. 'brx': 3,
  3333. 'bs': 11,
  3334. 'ca': 3,
  3335. 'cgg': 3,
  3336. 'chr': 3,
  3337. 'cs': 12,
  3338. 'cy': 17,
  3339. 'da': 3,
  3340. 'de': 3,
  3341. 'dv': 3,
  3342. 'dz': 0,
  3343. 'ee': 3,
  3344. 'el': 3,
  3345. 'en': 3,
  3346. 'eo': 3,
  3347. 'es': 3,
  3348. 'et': 3,
  3349. 'eu': 3,
  3350. 'fa': 0,
  3351. 'ff': 5,
  3352. 'fi': 3,
  3353. 'fil': 4,
  3354. 'fo': 3,
  3355. 'fr': 5,
  3356. 'fur': 3,
  3357. 'fy': 3,
  3358. 'ga': 8,
  3359. 'gd': 24,
  3360. 'gl': 3,
  3361. 'gsw': 3,
  3362. 'gu': 3,
  3363. 'guw': 4,
  3364. 'gv': 23,
  3365. 'ha': 3,
  3366. 'haw': 3,
  3367. 'he': 2,
  3368. 'hi': 4,
  3369. 'hr': 11,
  3370. 'hu': 0,
  3371. 'id': 0,
  3372. 'ig': 0,
  3373. 'ii': 0,
  3374. 'is': 3,
  3375. 'it': 3,
  3376. 'iu': 7,
  3377. 'ja': 0,
  3378. 'jmc': 3,
  3379. 'jv': 0,
  3380. 'ka': 0,
  3381. 'kab': 5,
  3382. 'kaj': 3,
  3383. 'kcg': 3,
  3384. 'kde': 0,
  3385. 'kea': 0,
  3386. 'kk': 3,
  3387. 'kl': 3,
  3388. 'km': 0,
  3389. 'kn': 0,
  3390. 'ko': 0,
  3391. 'ksb': 3,
  3392. 'ksh': 21,
  3393. 'ku': 3,
  3394. 'kw': 7,
  3395. 'lag': 18,
  3396. 'lb': 3,
  3397. 'lg': 3,
  3398. 'ln': 4,
  3399. 'lo': 0,
  3400. 'lt': 10,
  3401. 'lv': 6,
  3402. 'mas': 3,
  3403. 'mg': 4,
  3404. 'mk': 16,
  3405. 'ml': 3,
  3406. 'mn': 3,
  3407. 'mo': 9,
  3408. 'mr': 3,
  3409. 'ms': 0,
  3410. 'mt': 15,
  3411. 'my': 0,
  3412. 'nah': 3,
  3413. 'naq': 7,
  3414. 'nb': 3,
  3415. 'nd': 3,
  3416. 'ne': 3,
  3417. 'nl': 3,
  3418. 'nn': 3,
  3419. 'no': 3,
  3420. 'nr': 3,
  3421. 'nso': 4,
  3422. 'ny': 3,
  3423. 'nyn': 3,
  3424. 'om': 3,
  3425. 'or': 3,
  3426. 'pa': 3,
  3427. 'pap': 3,
  3428. 'pl': 13,
  3429. 'ps': 3,
  3430. 'pt': 3,
  3431. 'rm': 3,
  3432. 'ro': 9,
  3433. 'rof': 3,
  3434. 'ru': 11,
  3435. 'rwk': 3,
  3436. 'sah': 0,
  3437. 'saq': 3,
  3438. 'se': 7,
  3439. 'seh': 3,
  3440. 'ses': 0,
  3441. 'sg': 0,
  3442. 'sh': 11,
  3443. 'shi': 19,
  3444. 'sk': 12,
  3445. 'sl': 14,
  3446. 'sma': 7,
  3447. 'smi': 7,
  3448. 'smj': 7,
  3449. 'smn': 7,
  3450. 'sms': 7,
  3451. 'sn': 3,
  3452. 'so': 3,
  3453. 'sq': 3,
  3454. 'sr': 11,
  3455. 'ss': 3,
  3456. 'ssy': 3,
  3457. 'st': 3,
  3458. 'sv': 3,
  3459. 'sw': 3,
  3460. 'syr': 3,
  3461. 'ta': 3,
  3462. 'te': 3,
  3463. 'teo': 3,
  3464. 'th': 0,
  3465. 'ti': 4,
  3466. 'tig': 3,
  3467. 'tk': 3,
  3468. 'tl': 4,
  3469. 'tn': 3,
  3470. 'to': 0,
  3471. 'tr': 0,
  3472. 'ts': 3,
  3473. 'tzm': 22,
  3474. 'uk': 11,
  3475. 'ur': 3,
  3476. 've': 3,
  3477. 'vi': 0,
  3478. 'vun': 3,
  3479. 'wa': 4,
  3480. 'wae': 3,
  3481. 'wo': 0,
  3482. 'xh': 3,
  3483. 'xog': 3,
  3484. 'yo': 0,
  3485. 'zh': 0,
  3486. 'zu': 3
  3487. };
  3488. function isIn(n, list) {
  3489. return list.indexOf(n) !== -1;
  3490. }
  3491. function isBetween(n, start, end) {
  3492. return start <= n && n <= end;
  3493. }
  3494. var pluralRules = {
  3495. '0': function _(n) {
  3496. return 'other';
  3497. },
  3498. '1': function _(n) {
  3499. if (isBetween(n % 100, 3, 10)) return 'few';
  3500. if (n === 0) return 'zero';
  3501. if (isBetween(n % 100, 11, 99)) return 'many';
  3502. if (n == 2) return 'two';
  3503. if (n == 1) return 'one';
  3504. return 'other';
  3505. },
  3506. '2': function _(n) {
  3507. if (n !== 0 && n % 10 === 0) return 'many';
  3508. if (n == 2) return 'two';
  3509. if (n == 1) return 'one';
  3510. return 'other';
  3511. },
  3512. '3': function _(n) {
  3513. if (n == 1) return 'one';
  3514. return 'other';
  3515. },
  3516. '4': function _(n) {
  3517. if (isBetween(n, 0, 1)) return 'one';
  3518. return 'other';
  3519. },
  3520. '5': function _(n) {
  3521. if (isBetween(n, 0, 2) && n != 2) return 'one';
  3522. return 'other';
  3523. },
  3524. '6': function _(n) {
  3525. if (n === 0) return 'zero';
  3526. if (n % 10 == 1 && n % 100 != 11) return 'one';
  3527. return 'other';
  3528. },
  3529. '7': function _(n) {
  3530. if (n == 2) return 'two';
  3531. if (n == 1) return 'one';
  3532. return 'other';
  3533. },
  3534. '8': function _(n) {
  3535. if (isBetween(n, 3, 6)) return 'few';
  3536. if (isBetween(n, 7, 10)) return 'many';
  3537. if (n == 2) return 'two';
  3538. if (n == 1) return 'one';
  3539. return 'other';
  3540. },
  3541. '9': function _(n) {
  3542. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  3543. if (n == 1) return 'one';
  3544. return 'other';
  3545. },
  3546. '10': function _(n) {
  3547. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  3548. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  3549. return 'other';
  3550. },
  3551. '11': function _(n) {
  3552. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  3553. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  3554. if (n % 10 == 1 && n % 100 != 11) return 'one';
  3555. return 'other';
  3556. },
  3557. '12': function _(n) {
  3558. if (isBetween(n, 2, 4)) return 'few';
  3559. if (n == 1) return 'one';
  3560. return 'other';
  3561. },
  3562. '13': function _(n) {
  3563. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  3564. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  3565. if (n == 1) return 'one';
  3566. return 'other';
  3567. },
  3568. '14': function _(n) {
  3569. if (isBetween(n % 100, 3, 4)) return 'few';
  3570. if (n % 100 == 2) return 'two';
  3571. if (n % 100 == 1) return 'one';
  3572. return 'other';
  3573. },
  3574. '15': function _(n) {
  3575. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  3576. if (isBetween(n % 100, 11, 19)) return 'many';
  3577. if (n == 1) return 'one';
  3578. return 'other';
  3579. },
  3580. '16': function _(n) {
  3581. if (n % 10 == 1 && n != 11) return 'one';
  3582. return 'other';
  3583. },
  3584. '17': function _(n) {
  3585. if (n == 3) return 'few';
  3586. if (n === 0) return 'zero';
  3587. if (n == 6) return 'many';
  3588. if (n == 2) return 'two';
  3589. if (n == 1) return 'one';
  3590. return 'other';
  3591. },
  3592. '18': function _(n) {
  3593. if (n === 0) return 'zero';
  3594. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  3595. return 'other';
  3596. },
  3597. '19': function _(n) {
  3598. if (isBetween(n, 2, 10)) return 'few';
  3599. if (isBetween(n, 0, 1)) return 'one';
  3600. return 'other';
  3601. },
  3602. '20': function _(n) {
  3603. if ((isBetween(n % 10, 3, 4) || n % 10 == 9) && !(isBetween(n % 100, 10, 19) || isBetween(n % 100, 70, 79) || isBetween(n % 100, 90, 99))) return 'few';
  3604. if (n % 1000000 === 0 && n !== 0) return 'many';
  3605. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  3606. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  3607. return 'other';
  3608. },
  3609. '21': function _(n) {
  3610. if (n === 0) return 'zero';
  3611. if (n == 1) return 'one';
  3612. return 'other';
  3613. },
  3614. '22': function _(n) {
  3615. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  3616. return 'other';
  3617. },
  3618. '23': function _(n) {
  3619. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  3620. return 'other';
  3621. },
  3622. '24': function _(n) {
  3623. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  3624. if (isIn(n, [2, 12])) return 'two';
  3625. if (isIn(n, [1, 11])) return 'one';
  3626. return 'other';
  3627. }
  3628. };
  3629. var index = locales2rules[lang.replace(/-.*$/, '')];
  3630. if (!(index in pluralRules)) {
  3631. console.warn('plural form unknown for [' + lang + ']');
  3632. return function () {
  3633. return 'other';
  3634. };
  3635. }
  3636. return pluralRules[index];
  3637. }
  3638. gMacros.plural = function (str, param, key, prop) {
  3639. var n = parseFloat(param);
  3640. if (isNaN(n)) return str;
  3641. if (prop != gTextProp) return str;
  3642. if (!gMacros._pluralRules) {
  3643. gMacros._pluralRules = getPluralRules(gLanguage);
  3644. }
  3645. var index = '[' + gMacros._pluralRules(n) + ']';
  3646. if (n === 0 && key + '[zero]' in gL10nData) {
  3647. str = gL10nData[key + '[zero]'][prop];
  3648. } else if (n == 1 && key + '[one]' in gL10nData) {
  3649. str = gL10nData[key + '[one]'][prop];
  3650. } else if (n == 2 && key + '[two]' in gL10nData) {
  3651. str = gL10nData[key + '[two]'][prop];
  3652. } else if (key + index in gL10nData) {
  3653. str = gL10nData[key + index][prop];
  3654. } else if (key + '[other]' in gL10nData) {
  3655. str = gL10nData[key + '[other]'][prop];
  3656. }
  3657. return str;
  3658. };
  3659. function getL10nData(key, args, fallback) {
  3660. var data = gL10nData[key];
  3661. if (!data) {
  3662. console.warn('#' + key + ' is undefined.');
  3663. if (!fallback) {
  3664. return null;
  3665. }
  3666. data = fallback;
  3667. }
  3668. var rv = {};
  3669. for (var prop in data) {
  3670. var str = data[prop];
  3671. str = substIndexes(str, args, key, prop);
  3672. str = substArguments(str, args, key);
  3673. rv[prop] = str;
  3674. }
  3675. return rv;
  3676. }
  3677. function substIndexes(str, args, key, prop) {
  3678. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  3679. var reMatch = reIndex.exec(str);
  3680. if (!reMatch || !reMatch.length) return str;
  3681. var macroName = reMatch[1];
  3682. var paramName = reMatch[2];
  3683. var param;
  3684. if (args && paramName in args) {
  3685. param = args[paramName];
  3686. } else if (paramName in gL10nData) {
  3687. param = gL10nData[paramName];
  3688. }
  3689. if (macroName in gMacros) {
  3690. var macro = gMacros[macroName];
  3691. str = macro(str, param, key, prop);
  3692. }
  3693. return str;
  3694. }
  3695. function substArguments(str, args, key) {
  3696. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  3697. return str.replace(reArgs, function (matched_text, arg) {
  3698. if (args && arg in args) {
  3699. return args[arg];
  3700. }
  3701. if (arg in gL10nData) {
  3702. return gL10nData[arg];
  3703. }
  3704. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  3705. return matched_text;
  3706. });
  3707. }
  3708. function translateElement(element) {
  3709. var l10n = getL10nAttributes(element);
  3710. if (!l10n.id) return;
  3711. var data = getL10nData(l10n.id, l10n.args);
  3712. if (!data) {
  3713. console.warn('#' + l10n.id + ' is undefined.');
  3714. return;
  3715. }
  3716. if (data[gTextProp]) {
  3717. if (getChildElementCount(element) === 0) {
  3718. element[gTextProp] = data[gTextProp];
  3719. } else {
  3720. var children = element.childNodes;
  3721. var found = false;
  3722. for (var i = 0, l = children.length; i < l; i++) {
  3723. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  3724. if (found) {
  3725. children[i].nodeValue = '';
  3726. } else {
  3727. children[i].nodeValue = data[gTextProp];
  3728. found = true;
  3729. }
  3730. }
  3731. }
  3732. if (!found) {
  3733. var textNode = document.createTextNode(data[gTextProp]);
  3734. element.insertBefore(textNode, element.firstChild);
  3735. }
  3736. }
  3737. delete data[gTextProp];
  3738. }
  3739. for (var k in data) {
  3740. element[k] = data[k];
  3741. }
  3742. }
  3743. function getChildElementCount(element) {
  3744. if (element.children) {
  3745. return element.children.length;
  3746. }
  3747. if (typeof element.childElementCount !== 'undefined') {
  3748. return element.childElementCount;
  3749. }
  3750. var count = 0;
  3751. for (var i = 0; i < element.childNodes.length; i++) {
  3752. count += element.nodeType === 1 ? 1 : 0;
  3753. }
  3754. return count;
  3755. }
  3756. function translateFragment(element) {
  3757. element = element || document.documentElement;
  3758. var children = getTranslatableChildren(element);
  3759. var elementCount = children.length;
  3760. for (var i = 0; i < elementCount; i++) {
  3761. translateElement(children[i]);
  3762. }
  3763. translateElement(element);
  3764. }
  3765. return {
  3766. get: function get(key, args, fallbackString) {
  3767. var index = key.lastIndexOf('.');
  3768. var prop = gTextProp;
  3769. if (index > 0) {
  3770. prop = key.substr(index + 1);
  3771. key = key.substring(0, index);
  3772. }
  3773. var fallback;
  3774. if (fallbackString) {
  3775. fallback = {};
  3776. fallback[prop] = fallbackString;
  3777. }
  3778. var data = getL10nData(key, args, fallback);
  3779. if (data && prop in data) {
  3780. return data[prop];
  3781. }
  3782. return '{{' + key + '}}';
  3783. },
  3784. getData: function getData() {
  3785. return gL10nData;
  3786. },
  3787. getText: function getText() {
  3788. return gTextData;
  3789. },
  3790. getLanguage: function getLanguage() {
  3791. return gLanguage;
  3792. },
  3793. setLanguage: function setLanguage(lang, callback) {
  3794. loadLocale(lang, function () {
  3795. if (callback) callback();
  3796. });
  3797. },
  3798. getDirection: function getDirection() {
  3799. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  3800. var shortCode = gLanguage.split('-', 1)[0];
  3801. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  3802. },
  3803. translate: translateFragment,
  3804. getReadyState: function getReadyState() {
  3805. return gReadyState;
  3806. },
  3807. ready: function ready(callback) {
  3808. if (!callback) {
  3809. return;
  3810. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  3811. window.setTimeout(function () {
  3812. callback();
  3813. });
  3814. } else if (document.addEventListener) {
  3815. document.addEventListener('localized', function once() {
  3816. document.removeEventListener('localized', once);
  3817. callback();
  3818. });
  3819. }
  3820. }
  3821. };
  3822. }(window, document);
  3823. /***/ }),
  3824. /* 13 */
  3825. /***/ (function(module, exports, __w_pdfjs_require__) {
  3826. "use strict";
  3827. Object.defineProperty(exports, "__esModule", {
  3828. value: true
  3829. });
  3830. exports.PDFFindController = exports.FindState = undefined;
  3831. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3832. var _pdfjsLib = __w_pdfjs_require__(0);
  3833. var _ui_utils = __w_pdfjs_require__(1);
  3834. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3835. var FindState = {
  3836. FOUND: 0,
  3837. NOT_FOUND: 1,
  3838. WRAPPED: 2,
  3839. PENDING: 3
  3840. };
  3841. var FIND_SCROLL_OFFSET_TOP = -50;
  3842. var FIND_SCROLL_OFFSET_LEFT = -400;
  3843. var FIND_TIMEOUT = 250;
  3844. var CHARACTERS_TO_NORMALIZE = {
  3845. '\u2018': '\'',
  3846. '\u2019': '\'',
  3847. '\u201A': '\'',
  3848. '\u201B': '\'',
  3849. '\u201C': '"',
  3850. '\u201D': '"',
  3851. '\u201E': '"',
  3852. '\u201F': '"',
  3853. '\xBC': '1/4',
  3854. '\xBD': '1/2',
  3855. '\xBE': '3/4'
  3856. };
  3857. var PDFFindController = function () {
  3858. function PDFFindController(_ref) {
  3859. var pdfViewer = _ref.pdfViewer;
  3860. _classCallCheck(this, PDFFindController);
  3861. this.pdfViewer = pdfViewer;
  3862. this.onUpdateResultsCount = null;
  3863. this.onUpdateState = null;
  3864. this.reset();
  3865. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
  3866. this.normalizationRegex = new RegExp('[' + replace + ']', 'g');
  3867. }
  3868. _createClass(PDFFindController, [{
  3869. key: 'reset',
  3870. value: function reset() {
  3871. var _this = this;
  3872. this.startedTextExtraction = false;
  3873. this.extractTextPromises = [];
  3874. this.pendingFindMatches = Object.create(null);
  3875. this.active = false;
  3876. this.pageContents = [];
  3877. this.pageMatches = [];
  3878. this.pageMatchesLength = null;
  3879. this.matchCount = 0;
  3880. this.selected = {
  3881. pageIdx: -1,
  3882. matchIdx: -1
  3883. };
  3884. this.offset = {
  3885. pageIdx: null,
  3886. matchIdx: null
  3887. };
  3888. this.pagesToSearch = null;
  3889. this.resumePageIdx = null;
  3890. this.state = null;
  3891. this.dirtyMatch = false;
  3892. this.findTimeout = null;
  3893. this._firstPagePromise = new Promise(function (resolve) {
  3894. _this.resolveFirstPage = resolve;
  3895. });
  3896. }
  3897. }, {
  3898. key: 'normalize',
  3899. value: function normalize(text) {
  3900. return text.replace(this.normalizationRegex, function (ch) {
  3901. return CHARACTERS_TO_NORMALIZE[ch];
  3902. });
  3903. }
  3904. }, {
  3905. key: '_prepareMatches',
  3906. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  3907. function isSubTerm(matchesWithLength, currentIndex) {
  3908. var currentElem = matchesWithLength[currentIndex];
  3909. var nextElem = matchesWithLength[currentIndex + 1];
  3910. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  3911. currentElem.skipped = true;
  3912. return true;
  3913. }
  3914. for (var i = currentIndex - 1; i >= 0; i--) {
  3915. var prevElem = matchesWithLength[i];
  3916. if (prevElem.skipped) {
  3917. continue;
  3918. }
  3919. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  3920. break;
  3921. }
  3922. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  3923. currentElem.skipped = true;
  3924. return true;
  3925. }
  3926. }
  3927. return false;
  3928. }
  3929. matchesWithLength.sort(function (a, b) {
  3930. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  3931. });
  3932. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  3933. if (isSubTerm(matchesWithLength, i)) {
  3934. continue;
  3935. }
  3936. matches.push(matchesWithLength[i].match);
  3937. matchesLength.push(matchesWithLength[i].matchLength);
  3938. }
  3939. }
  3940. }, {
  3941. key: 'calcFindPhraseMatch',
  3942. value: function calcFindPhraseMatch(query, pageIndex, pageContent) {
  3943. var matches = [];
  3944. var queryLen = query.length;
  3945. var matchIdx = -queryLen;
  3946. while (true) {
  3947. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  3948. if (matchIdx === -1) {
  3949. break;
  3950. }
  3951. matches.push(matchIdx);
  3952. }
  3953. this.pageMatches[pageIndex] = matches;
  3954. }
  3955. }, {
  3956. key: 'calcFindWordMatch',
  3957. value: function calcFindWordMatch(query, pageIndex, pageContent) {
  3958. var matchesWithLength = [];
  3959. var queryArray = query.match(/\S+/g);
  3960. for (var i = 0, len = queryArray.length; i < len; i++) {
  3961. var subquery = queryArray[i];
  3962. var subqueryLen = subquery.length;
  3963. var matchIdx = -subqueryLen;
  3964. while (true) {
  3965. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  3966. if (matchIdx === -1) {
  3967. break;
  3968. }
  3969. matchesWithLength.push({
  3970. match: matchIdx,
  3971. matchLength: subqueryLen,
  3972. skipped: false
  3973. });
  3974. }
  3975. }
  3976. if (!this.pageMatchesLength) {
  3977. this.pageMatchesLength = [];
  3978. }
  3979. this.pageMatchesLength[pageIndex] = [];
  3980. this.pageMatches[pageIndex] = [];
  3981. this._prepareMatches(matchesWithLength, this.pageMatches[pageIndex], this.pageMatchesLength[pageIndex]);
  3982. }
  3983. }, {
  3984. key: 'calcFindMatch',
  3985. value: function calcFindMatch(pageIndex) {
  3986. var pageContent = this.normalize(this.pageContents[pageIndex]);
  3987. var query = this.normalize(this.state.query);
  3988. var caseSensitive = this.state.caseSensitive;
  3989. var phraseSearch = this.state.phraseSearch;
  3990. var queryLen = query.length;
  3991. if (queryLen === 0) {
  3992. return;
  3993. }
  3994. if (!caseSensitive) {
  3995. pageContent = pageContent.toLowerCase();
  3996. query = query.toLowerCase();
  3997. }
  3998. if (phraseSearch) {
  3999. this.calcFindPhraseMatch(query, pageIndex, pageContent);
  4000. } else {
  4001. this.calcFindWordMatch(query, pageIndex, pageContent);
  4002. }
  4003. this.updatePage(pageIndex);
  4004. if (this.resumePageIdx === pageIndex) {
  4005. this.resumePageIdx = null;
  4006. this.nextPageMatch();
  4007. }
  4008. if (this.pageMatches[pageIndex].length > 0) {
  4009. this.matchCount += this.pageMatches[pageIndex].length;
  4010. this.updateUIResultsCount();
  4011. }
  4012. }
  4013. }, {
  4014. key: 'extractText',
  4015. value: function extractText() {
  4016. var _this2 = this;
  4017. if (this.startedTextExtraction) {
  4018. return;
  4019. }
  4020. this.startedTextExtraction = true;
  4021. this.pageContents.length = 0;
  4022. var promise = Promise.resolve();
  4023. var _loop = function _loop(i, ii) {
  4024. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  4025. _this2.extractTextPromises[i] = extractTextCapability.promise;
  4026. promise = promise.then(function () {
  4027. return _this2.pdfViewer.getPageTextContent(i).then(function (textContent) {
  4028. var textItems = textContent.items;
  4029. var strBuf = [];
  4030. for (var j = 0, jj = textItems.length; j < jj; j++) {
  4031. strBuf.push(textItems[j].str);
  4032. }
  4033. _this2.pageContents[i] = strBuf.join('');
  4034. extractTextCapability.resolve(i);
  4035. }, function (reason) {
  4036. console.error('Unable to get page ' + (i + 1) + ' text content', reason);
  4037. _this2.pageContents[i] = '';
  4038. extractTextCapability.resolve(i);
  4039. });
  4040. });
  4041. };
  4042. for (var i = 0, ii = this.pdfViewer.pagesCount; i < ii; i++) {
  4043. _loop(i, ii);
  4044. }
  4045. }
  4046. }, {
  4047. key: 'executeCommand',
  4048. value: function executeCommand(cmd, state) {
  4049. var _this3 = this;
  4050. if (this.state === null || cmd !== 'findagain') {
  4051. this.dirtyMatch = true;
  4052. }
  4053. this.state = state;
  4054. this.updateUIState(FindState.PENDING);
  4055. this._firstPagePromise.then(function () {
  4056. _this3.extractText();
  4057. clearTimeout(_this3.findTimeout);
  4058. if (cmd === 'find') {
  4059. _this3.findTimeout = setTimeout(_this3.nextMatch.bind(_this3), FIND_TIMEOUT);
  4060. } else {
  4061. _this3.nextMatch();
  4062. }
  4063. });
  4064. }
  4065. }, {
  4066. key: 'updatePage',
  4067. value: function updatePage(index) {
  4068. if (this.selected.pageIdx === index) {
  4069. this.pdfViewer.currentPageNumber = index + 1;
  4070. }
  4071. var page = this.pdfViewer.getPageView(index);
  4072. if (page.textLayer) {
  4073. page.textLayer.updateMatches();
  4074. }
  4075. }
  4076. }, {
  4077. key: 'nextMatch',
  4078. value: function nextMatch() {
  4079. var _this4 = this;
  4080. var previous = this.state.findPrevious;
  4081. var currentPageIndex = this.pdfViewer.currentPageNumber - 1;
  4082. var numPages = this.pdfViewer.pagesCount;
  4083. this.active = true;
  4084. if (this.dirtyMatch) {
  4085. this.dirtyMatch = false;
  4086. this.selected.pageIdx = this.selected.matchIdx = -1;
  4087. this.offset.pageIdx = currentPageIndex;
  4088. this.offset.matchIdx = null;
  4089. this.hadMatch = false;
  4090. this.resumePageIdx = null;
  4091. this.pageMatches = [];
  4092. this.matchCount = 0;
  4093. this.pageMatchesLength = null;
  4094. for (var i = 0; i < numPages; i++) {
  4095. this.updatePage(i);
  4096. if (!(i in this.pendingFindMatches)) {
  4097. this.pendingFindMatches[i] = true;
  4098. this.extractTextPromises[i].then(function (pageIdx) {
  4099. delete _this4.pendingFindMatches[pageIdx];
  4100. _this4.calcFindMatch(pageIdx);
  4101. });
  4102. }
  4103. }
  4104. }
  4105. if (this.state.query === '') {
  4106. this.updateUIState(FindState.FOUND);
  4107. return;
  4108. }
  4109. if (this.resumePageIdx) {
  4110. return;
  4111. }
  4112. var offset = this.offset;
  4113. this.pagesToSearch = numPages;
  4114. if (offset.matchIdx !== null) {
  4115. var numPageMatches = this.pageMatches[offset.pageIdx].length;
  4116. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  4117. this.hadMatch = true;
  4118. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  4119. this.updateMatch(true);
  4120. return;
  4121. }
  4122. this.advanceOffsetPage(previous);
  4123. }
  4124. this.nextPageMatch();
  4125. }
  4126. }, {
  4127. key: 'matchesReady',
  4128. value: function matchesReady(matches) {
  4129. var offset = this.offset;
  4130. var numMatches = matches.length;
  4131. var previous = this.state.findPrevious;
  4132. if (numMatches) {
  4133. this.hadMatch = true;
  4134. offset.matchIdx = previous ? numMatches - 1 : 0;
  4135. this.updateMatch(true);
  4136. return true;
  4137. }
  4138. this.advanceOffsetPage(previous);
  4139. if (offset.wrapped) {
  4140. offset.matchIdx = null;
  4141. if (this.pagesToSearch < 0) {
  4142. this.updateMatch(false);
  4143. return true;
  4144. }
  4145. }
  4146. return false;
  4147. }
  4148. }, {
  4149. key: 'updateMatchPosition',
  4150. value: function updateMatchPosition(pageIndex, matchIndex, elements, beginIdx) {
  4151. if (this.selected.matchIdx === matchIndex && this.selected.pageIdx === pageIndex) {
  4152. var spot = {
  4153. top: FIND_SCROLL_OFFSET_TOP,
  4154. left: FIND_SCROLL_OFFSET_LEFT
  4155. };
  4156. (0, _ui_utils.scrollIntoView)(elements[beginIdx], spot, true);
  4157. }
  4158. }
  4159. }, {
  4160. key: 'nextPageMatch',
  4161. value: function nextPageMatch() {
  4162. if (this.resumePageIdx !== null) {
  4163. console.error('There can only be one pending page.');
  4164. }
  4165. var matches = null;
  4166. do {
  4167. var pageIdx = this.offset.pageIdx;
  4168. matches = this.pageMatches[pageIdx];
  4169. if (!matches) {
  4170. this.resumePageIdx = pageIdx;
  4171. break;
  4172. }
  4173. } while (!this.matchesReady(matches));
  4174. }
  4175. }, {
  4176. key: 'advanceOffsetPage',
  4177. value: function advanceOffsetPage(previous) {
  4178. var offset = this.offset;
  4179. var numPages = this.extractTextPromises.length;
  4180. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  4181. offset.matchIdx = null;
  4182. this.pagesToSearch--;
  4183. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  4184. offset.pageIdx = previous ? numPages - 1 : 0;
  4185. offset.wrapped = true;
  4186. }
  4187. }
  4188. }, {
  4189. key: 'updateMatch',
  4190. value: function updateMatch() {
  4191. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4192. var state = FindState.NOT_FOUND;
  4193. var wrapped = this.offset.wrapped;
  4194. this.offset.wrapped = false;
  4195. if (found) {
  4196. var previousPage = this.selected.pageIdx;
  4197. this.selected.pageIdx = this.offset.pageIdx;
  4198. this.selected.matchIdx = this.offset.matchIdx;
  4199. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  4200. if (previousPage !== -1 && previousPage !== this.selected.pageIdx) {
  4201. this.updatePage(previousPage);
  4202. }
  4203. }
  4204. this.updateUIState(state, this.state.findPrevious);
  4205. if (this.selected.pageIdx !== -1) {
  4206. this.updatePage(this.selected.pageIdx);
  4207. }
  4208. }
  4209. }, {
  4210. key: 'updateUIResultsCount',
  4211. value: function updateUIResultsCount() {
  4212. if (this.onUpdateResultsCount) {
  4213. this.onUpdateResultsCount(this.matchCount);
  4214. }
  4215. }
  4216. }, {
  4217. key: 'updateUIState',
  4218. value: function updateUIState(state, previous) {
  4219. if (this.onUpdateState) {
  4220. this.onUpdateState(state, previous, this.matchCount);
  4221. }
  4222. }
  4223. }]);
  4224. return PDFFindController;
  4225. }();
  4226. exports.FindState = FindState;
  4227. exports.PDFFindController = PDFFindController;
  4228. /***/ }),
  4229. /* 14 */
  4230. /***/ (function(module, exports, __w_pdfjs_require__) {
  4231. "use strict";
  4232. Object.defineProperty(exports, "__esModule", {
  4233. value: true
  4234. });
  4235. exports.isDestArraysEqual = exports.isDestHashesEqual = exports.PDFHistory = undefined;
  4236. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  4237. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4238. var _ui_utils = __w_pdfjs_require__(1);
  4239. var _dom_events = __w_pdfjs_require__(2);
  4240. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4241. var HASH_CHANGE_TIMEOUT = 1000;
  4242. var POSITION_UPDATED_THRESHOLD = 50;
  4243. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  4244. function getCurrentHash() {
  4245. return document.location.hash;
  4246. }
  4247. function parseCurrentHash(linkService) {
  4248. var hash = unescape(getCurrentHash()).substring(1);
  4249. var params = (0, _ui_utils.parseQueryString)(hash);
  4250. var page = params.page | 0;
  4251. if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) {
  4252. page = null;
  4253. }
  4254. return {
  4255. hash: hash,
  4256. page: page,
  4257. rotation: linkService.rotation
  4258. };
  4259. }
  4260. var PDFHistory = function () {
  4261. function PDFHistory(_ref) {
  4262. var _this = this;
  4263. var linkService = _ref.linkService,
  4264. eventBus = _ref.eventBus;
  4265. _classCallCheck(this, PDFHistory);
  4266. this.linkService = linkService;
  4267. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  4268. this.initialized = false;
  4269. this.initialBookmark = null;
  4270. this.initialRotation = null;
  4271. this._boundEvents = Object.create(null);
  4272. this._isViewerInPresentationMode = false;
  4273. this._isPagesLoaded = false;
  4274. this.eventBus.on('presentationmodechanged', function (evt) {
  4275. _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
  4276. });
  4277. this.eventBus.on('pagesloaded', function (evt) {
  4278. _this._isPagesLoaded = !!evt.pagesCount;
  4279. });
  4280. }
  4281. _createClass(PDFHistory, [{
  4282. key: 'initialize',
  4283. value: function initialize(fingerprint) {
  4284. var resetHistory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4285. if (!fingerprint || typeof fingerprint !== 'string') {
  4286. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  4287. return;
  4288. }
  4289. var reInitialized = this.initialized && this.fingerprint !== fingerprint;
  4290. this.fingerprint = fingerprint;
  4291. if (!this.initialized) {
  4292. this._bindEvents();
  4293. }
  4294. var state = window.history.state;
  4295. this.initialized = true;
  4296. this.initialBookmark = null;
  4297. this.initialRotation = null;
  4298. this._popStateInProgress = false;
  4299. this._blockHashChange = 0;
  4300. this._currentHash = getCurrentHash();
  4301. this._numPositionUpdates = 0;
  4302. this._uid = this._maxUid = 0;
  4303. this._destination = null;
  4304. this._position = null;
  4305. if (!this._isValidState(state) || resetHistory) {
  4306. var _parseCurrentHash = parseCurrentHash(this.linkService),
  4307. hash = _parseCurrentHash.hash,
  4308. page = _parseCurrentHash.page,
  4309. rotation = _parseCurrentHash.rotation;
  4310. if (!hash || reInitialized || resetHistory) {
  4311. this._pushOrReplaceState(null, true);
  4312. return;
  4313. }
  4314. this._pushOrReplaceState({
  4315. hash: hash,
  4316. page: page,
  4317. rotation: rotation
  4318. }, true);
  4319. return;
  4320. }
  4321. var destination = state.destination;
  4322. this._updateInternalState(destination, state.uid, true);
  4323. if (destination.rotation !== undefined) {
  4324. this.initialRotation = destination.rotation;
  4325. }
  4326. if (destination.dest) {
  4327. this.initialBookmark = JSON.stringify(destination.dest);
  4328. this._destination.page = null;
  4329. } else if (destination.hash) {
  4330. this.initialBookmark = destination.hash;
  4331. } else if (destination.page) {
  4332. this.initialBookmark = 'page=' + destination.page;
  4333. }
  4334. }
  4335. }, {
  4336. key: 'push',
  4337. value: function push(_ref2) {
  4338. var _this2 = this;
  4339. var namedDest = _ref2.namedDest,
  4340. explicitDest = _ref2.explicitDest,
  4341. pageNumber = _ref2.pageNumber;
  4342. if (!this.initialized) {
  4343. return;
  4344. }
  4345. if (namedDest && typeof namedDest !== 'string' || !(explicitDest instanceof Array) || !(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  4346. console.error('PDFHistory.push: Invalid parameters.');
  4347. return;
  4348. }
  4349. var hash = namedDest || JSON.stringify(explicitDest);
  4350. if (!hash) {
  4351. return;
  4352. }
  4353. var forceReplace = false;
  4354. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  4355. if (this._destination.page) {
  4356. return;
  4357. }
  4358. forceReplace = true;
  4359. }
  4360. if (this._popStateInProgress && !forceReplace) {
  4361. return;
  4362. }
  4363. this._pushOrReplaceState({
  4364. dest: explicitDest,
  4365. hash: hash,
  4366. page: pageNumber,
  4367. rotation: this.linkService.rotation
  4368. }, forceReplace);
  4369. if (!this._popStateInProgress) {
  4370. this._popStateInProgress = true;
  4371. Promise.resolve().then(function () {
  4372. _this2._popStateInProgress = false;
  4373. });
  4374. }
  4375. }
  4376. }, {
  4377. key: 'pushCurrentPosition',
  4378. value: function pushCurrentPosition() {
  4379. if (!this.initialized || this._popStateInProgress) {
  4380. return;
  4381. }
  4382. this._tryPushCurrentPosition();
  4383. }
  4384. }, {
  4385. key: 'back',
  4386. value: function back() {
  4387. if (!this.initialized || this._popStateInProgress) {
  4388. return;
  4389. }
  4390. var state = window.history.state;
  4391. if (this._isValidState(state) && state.uid > 0) {
  4392. window.history.back();
  4393. }
  4394. }
  4395. }, {
  4396. key: 'forward',
  4397. value: function forward() {
  4398. if (!this.initialized || this._popStateInProgress) {
  4399. return;
  4400. }
  4401. var state = window.history.state;
  4402. if (this._isValidState(state) && state.uid < this._maxUid) {
  4403. window.history.forward();
  4404. }
  4405. }
  4406. }, {
  4407. key: '_pushOrReplaceState',
  4408. value: function _pushOrReplaceState(destination) {
  4409. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4410. var shouldReplace = forceReplace || !this._destination;
  4411. var newState = {
  4412. fingerprint: this.fingerprint,
  4413. uid: shouldReplace ? this._uid : this._uid + 1,
  4414. destination: destination
  4415. };
  4416. this._updateInternalState(destination, newState.uid);
  4417. if (shouldReplace) {
  4418. window.history.replaceState(newState, '', document.URL);
  4419. } else {
  4420. this._maxUid = this._uid;
  4421. window.history.pushState(newState, '', document.URL);
  4422. }
  4423. }
  4424. }, {
  4425. key: '_tryPushCurrentPosition',
  4426. value: function _tryPushCurrentPosition() {
  4427. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4428. if (!this._position) {
  4429. return;
  4430. }
  4431. var position = this._position;
  4432. if (temporary) {
  4433. position = (0, _ui_utils.cloneObj)(this._position);
  4434. position.temporary = true;
  4435. }
  4436. if (!this._destination) {
  4437. this._pushOrReplaceState(position);
  4438. return;
  4439. }
  4440. if (this._destination.temporary) {
  4441. this._pushOrReplaceState(position, true);
  4442. return;
  4443. }
  4444. if (this._destination.hash === position.hash) {
  4445. return;
  4446. }
  4447. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  4448. return;
  4449. }
  4450. var forceReplace = false;
  4451. if (this._destination.page === position.first || this._destination.page === position.page) {
  4452. if (this._destination.dest || !this._destination.first) {
  4453. return;
  4454. }
  4455. forceReplace = true;
  4456. }
  4457. this._pushOrReplaceState(position, forceReplace);
  4458. }
  4459. }, {
  4460. key: '_isValidState',
  4461. value: function _isValidState(state) {
  4462. if (!state) {
  4463. return false;
  4464. }
  4465. if (state.fingerprint !== this.fingerprint) {
  4466. return false;
  4467. }
  4468. if (!Number.isInteger(state.uid) || state.uid < 0) {
  4469. return false;
  4470. }
  4471. if (state.destination === null || _typeof(state.destination) !== 'object') {
  4472. return false;
  4473. }
  4474. return true;
  4475. }
  4476. }, {
  4477. key: '_updateInternalState',
  4478. value: function _updateInternalState(destination, uid) {
  4479. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4480. if (this._updateViewareaTimeout) {
  4481. clearTimeout(this._updateViewareaTimeout);
  4482. this._updateViewareaTimeout = null;
  4483. }
  4484. if (removeTemporary && destination && destination.temporary) {
  4485. delete destination.temporary;
  4486. }
  4487. this._destination = destination;
  4488. this._uid = uid;
  4489. this._numPositionUpdates = 0;
  4490. }
  4491. }, {
  4492. key: '_updateViewarea',
  4493. value: function _updateViewarea(_ref3) {
  4494. var _this3 = this;
  4495. var location = _ref3.location;
  4496. if (this._updateViewareaTimeout) {
  4497. clearTimeout(this._updateViewareaTimeout);
  4498. this._updateViewareaTimeout = null;
  4499. }
  4500. this._position = {
  4501. hash: this._isViewerInPresentationMode ? 'page=' + location.pageNumber : location.pdfOpenParams.substring(1),
  4502. page: this.linkService.page,
  4503. first: location.pageNumber,
  4504. rotation: location.rotation
  4505. };
  4506. if (this._popStateInProgress) {
  4507. return;
  4508. }
  4509. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  4510. this._numPositionUpdates++;
  4511. }
  4512. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  4513. this._updateViewareaTimeout = setTimeout(function () {
  4514. if (!_this3._popStateInProgress) {
  4515. _this3._tryPushCurrentPosition(true);
  4516. }
  4517. _this3._updateViewareaTimeout = null;
  4518. }, UPDATE_VIEWAREA_TIMEOUT);
  4519. }
  4520. }
  4521. }, {
  4522. key: '_popState',
  4523. value: function _popState(_ref4) {
  4524. var _this4 = this;
  4525. var state = _ref4.state;
  4526. var newHash = getCurrentHash(),
  4527. hashChanged = this._currentHash !== newHash;
  4528. this._currentHash = newHash;
  4529. if (!state || false) {
  4530. this._uid++;
  4531. var _parseCurrentHash2 = parseCurrentHash(this.linkService),
  4532. hash = _parseCurrentHash2.hash,
  4533. page = _parseCurrentHash2.page,
  4534. rotation = _parseCurrentHash2.rotation;
  4535. this._pushOrReplaceState({
  4536. hash: hash,
  4537. page: page,
  4538. rotation: rotation
  4539. }, true);
  4540. return;
  4541. }
  4542. if (!this._isValidState(state)) {
  4543. return;
  4544. }
  4545. this._popStateInProgress = true;
  4546. if (hashChanged) {
  4547. this._blockHashChange++;
  4548. (0, _ui_utils.waitOnEventOrTimeout)({
  4549. target: window,
  4550. name: 'hashchange',
  4551. delay: HASH_CHANGE_TIMEOUT
  4552. }).then(function () {
  4553. _this4._blockHashChange--;
  4554. });
  4555. }
  4556. var destination = state.destination;
  4557. this._updateInternalState(destination, state.uid, true);
  4558. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  4559. this.linkService.rotation = destination.rotation;
  4560. }
  4561. if (destination.dest) {
  4562. this.linkService.navigateTo(destination.dest);
  4563. } else if (destination.hash) {
  4564. this.linkService.setHash(destination.hash);
  4565. } else if (destination.page) {
  4566. this.linkService.page = destination.page;
  4567. }
  4568. Promise.resolve().then(function () {
  4569. _this4._popStateInProgress = false;
  4570. });
  4571. }
  4572. }, {
  4573. key: '_bindEvents',
  4574. value: function _bindEvents() {
  4575. var _this5 = this;
  4576. var _boundEvents = this._boundEvents,
  4577. eventBus = this.eventBus;
  4578. _boundEvents.updateViewarea = this._updateViewarea.bind(this);
  4579. _boundEvents.popState = this._popState.bind(this);
  4580. _boundEvents.pageHide = function (evt) {
  4581. if (!_this5._destination) {
  4582. _this5._tryPushCurrentPosition();
  4583. }
  4584. };
  4585. eventBus.on('updateviewarea', _boundEvents.updateViewarea);
  4586. window.addEventListener('popstate', _boundEvents.popState);
  4587. window.addEventListener('pagehide', _boundEvents.pageHide);
  4588. }
  4589. }, {
  4590. key: 'popStateInProgress',
  4591. get: function get() {
  4592. return this.initialized && (this._popStateInProgress || this._blockHashChange > 0);
  4593. }
  4594. }]);
  4595. return PDFHistory;
  4596. }();
  4597. function isDestHashesEqual(destHash, pushHash) {
  4598. if (typeof destHash !== 'string' || typeof pushHash !== 'string') {
  4599. return false;
  4600. }
  4601. if (destHash === pushHash) {
  4602. return true;
  4603. }
  4604. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  4605. nameddest = _parseQueryString.nameddest;
  4606. if (nameddest === pushHash) {
  4607. return true;
  4608. }
  4609. return false;
  4610. }
  4611. function isDestArraysEqual(firstDest, secondDest) {
  4612. function isEntryEqual(first, second) {
  4613. if ((typeof first === 'undefined' ? 'undefined' : _typeof(first)) !== (typeof second === 'undefined' ? 'undefined' : _typeof(second))) {
  4614. return false;
  4615. }
  4616. if (first instanceof Array || second instanceof Array) {
  4617. return false;
  4618. }
  4619. if (first !== null && (typeof first === 'undefined' ? 'undefined' : _typeof(first)) === 'object' && second !== null) {
  4620. if (Object.keys(first).length !== Object.keys(second).length) {
  4621. return false;
  4622. }
  4623. for (var key in first) {
  4624. if (!isEntryEqual(first[key], second[key])) {
  4625. return false;
  4626. }
  4627. }
  4628. return true;
  4629. }
  4630. return first === second || Number.isNaN(first) && Number.isNaN(second);
  4631. }
  4632. if (!(firstDest instanceof Array && secondDest instanceof Array)) {
  4633. return false;
  4634. }
  4635. if (firstDest.length !== secondDest.length) {
  4636. return false;
  4637. }
  4638. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  4639. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  4640. return false;
  4641. }
  4642. }
  4643. return true;
  4644. }
  4645. exports.PDFHistory = PDFHistory;
  4646. exports.isDestHashesEqual = isDestHashesEqual;
  4647. exports.isDestArraysEqual = isDestArraysEqual;
  4648. /***/ }),
  4649. /* 15 */
  4650. /***/ (function(module, exports, __w_pdfjs_require__) {
  4651. "use strict";
  4652. Object.defineProperty(exports, "__esModule", {
  4653. value: true
  4654. });
  4655. exports.PDFSinglePageViewer = undefined;
  4656. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4657. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  4658. var _base_viewer = __w_pdfjs_require__(8);
  4659. var _ui_utils = __w_pdfjs_require__(1);
  4660. var _pdfjsLib = __w_pdfjs_require__(0);
  4661. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4662. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4663. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4664. var PDFSinglePageViewer = function (_BaseViewer) {
  4665. _inherits(PDFSinglePageViewer, _BaseViewer);
  4666. function PDFSinglePageViewer(options) {
  4667. _classCallCheck(this, PDFSinglePageViewer);
  4668. var _this = _possibleConstructorReturn(this, (PDFSinglePageViewer.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer)).call(this, options));
  4669. _this.eventBus.on('pagesinit', function (evt) {
  4670. _this._ensurePageViewVisible();
  4671. });
  4672. return _this;
  4673. }
  4674. _createClass(PDFSinglePageViewer, [{
  4675. key: '_resetView',
  4676. value: function _resetView() {
  4677. _get(PDFSinglePageViewer.prototype.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer.prototype), '_resetView', this).call(this);
  4678. this._previousPageNumber = 1;
  4679. this._shadowViewer = document.createDocumentFragment();
  4680. }
  4681. }, {
  4682. key: '_ensurePageViewVisible',
  4683. value: function _ensurePageViewVisible() {
  4684. var pageView = this._pages[this._currentPageNumber - 1];
  4685. var previousPageView = this._pages[this._previousPageNumber - 1];
  4686. var viewerNodes = this.viewer.childNodes;
  4687. switch (viewerNodes.length) {
  4688. case 0:
  4689. this.viewer.appendChild(pageView.div);
  4690. break;
  4691. case 1:
  4692. if (viewerNodes[0] !== previousPageView.div) {
  4693. throw new Error('_ensurePageViewVisible: Unexpected previously visible page.');
  4694. }
  4695. if (pageView === previousPageView) {
  4696. break;
  4697. }
  4698. this._shadowViewer.appendChild(previousPageView.div);
  4699. this.viewer.appendChild(pageView.div);
  4700. this.container.scrollTop = 0;
  4701. break;
  4702. default:
  4703. throw new Error('_ensurePageViewVisible: Only one page should be visible at a time.');
  4704. }
  4705. this._previousPageNumber = this._currentPageNumber;
  4706. }
  4707. }, {
  4708. key: '_scrollUpdate',
  4709. value: function _scrollUpdate() {
  4710. if (this._updateScrollDown) {
  4711. this._updateScrollDown();
  4712. }
  4713. _get(PDFSinglePageViewer.prototype.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer.prototype), '_scrollUpdate', this).call(this);
  4714. }
  4715. }, {
  4716. key: '_scrollIntoView',
  4717. value: function _scrollIntoView(_ref) {
  4718. var _this2 = this;
  4719. var pageDiv = _ref.pageDiv,
  4720. _ref$pageSpot = _ref.pageSpot,
  4721. pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot,
  4722. _ref$pageNumber = _ref.pageNumber,
  4723. pageNumber = _ref$pageNumber === undefined ? null : _ref$pageNumber;
  4724. if (pageNumber) {
  4725. this._setCurrentPageNumber(pageNumber);
  4726. }
  4727. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  4728. var previousLocation = this._location;
  4729. this._ensurePageViewVisible();
  4730. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  4731. this._updateScrollDown = function () {
  4732. _this2.scroll.down = scrolledDown;
  4733. delete _this2._updateScrollDown;
  4734. };
  4735. setTimeout(function () {
  4736. if (_this2._location === previousLocation) {
  4737. if (_this2._updateScrollDown) {
  4738. _this2._updateScrollDown();
  4739. }
  4740. _this2.update();
  4741. }
  4742. }, 0);
  4743. }
  4744. }, {
  4745. key: '_getVisiblePages',
  4746. value: function _getVisiblePages() {
  4747. if (!this.pagesCount) {
  4748. return { views: [] };
  4749. }
  4750. var pageView = this._pages[this._currentPageNumber - 1];
  4751. var element = pageView.div;
  4752. var view = {
  4753. id: pageView.id,
  4754. x: element.offsetLeft + element.clientLeft,
  4755. y: element.offsetTop + element.clientTop,
  4756. view: pageView
  4757. };
  4758. return {
  4759. first: view,
  4760. last: view,
  4761. views: [view]
  4762. };
  4763. }
  4764. }, {
  4765. key: 'update',
  4766. value: function update() {
  4767. var visible = this._getVisiblePages();
  4768. var visiblePages = visible.views,
  4769. numVisiblePages = visiblePages.length;
  4770. if (numVisiblePages === 0) {
  4771. return;
  4772. }
  4773. this._resizeBuffer(numVisiblePages);
  4774. this.renderingQueue.renderHighestPriority(visible);
  4775. this._updateLocation(visible.first);
  4776. this.eventBus.dispatch('updateviewarea', {
  4777. source: this,
  4778. location: this._location
  4779. });
  4780. }
  4781. }, {
  4782. key: '_setDocumentViewerElement',
  4783. get: function get() {
  4784. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this._shadowViewer);
  4785. }
  4786. }]);
  4787. return PDFSinglePageViewer;
  4788. }(_base_viewer.BaseViewer);
  4789. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  4790. /***/ }),
  4791. /* 16 */
  4792. /***/ (function(module, exports, __w_pdfjs_require__) {
  4793. "use strict";
  4794. Object.defineProperty(exports, "__esModule", {
  4795. value: true
  4796. });
  4797. exports.PDFViewer = undefined;
  4798. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4799. var _ui_utils = __w_pdfjs_require__(1);
  4800. var _base_viewer = __w_pdfjs_require__(8);
  4801. var _pdfjsLib = __w_pdfjs_require__(0);
  4802. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4803. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4804. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4805. var PDFViewer = function (_BaseViewer) {
  4806. _inherits(PDFViewer, _BaseViewer);
  4807. function PDFViewer() {
  4808. _classCallCheck(this, PDFViewer);
  4809. return _possibleConstructorReturn(this, (PDFViewer.__proto__ || Object.getPrototypeOf(PDFViewer)).apply(this, arguments));
  4810. }
  4811. _createClass(PDFViewer, [{
  4812. key: '_scrollIntoView',
  4813. value: function _scrollIntoView(_ref) {
  4814. var pageDiv = _ref.pageDiv,
  4815. _ref$pageSpot = _ref.pageSpot,
  4816. pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot;
  4817. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  4818. }
  4819. }, {
  4820. key: '_getVisiblePages',
  4821. value: function _getVisiblePages() {
  4822. if (!this.isInPresentationMode) {
  4823. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true);
  4824. }
  4825. var currentPage = this._pages[this._currentPageNumber - 1];
  4826. var visible = [{
  4827. id: currentPage.id,
  4828. view: currentPage
  4829. }];
  4830. return {
  4831. first: currentPage,
  4832. last: currentPage,
  4833. views: visible
  4834. };
  4835. }
  4836. }, {
  4837. key: 'update',
  4838. value: function update() {
  4839. var visible = this._getVisiblePages();
  4840. var visiblePages = visible.views,
  4841. numVisiblePages = visiblePages.length;
  4842. if (numVisiblePages === 0) {
  4843. return;
  4844. }
  4845. this._resizeBuffer(numVisiblePages);
  4846. this.renderingQueue.renderHighestPriority(visible);
  4847. var currentId = this._currentPageNumber;
  4848. var stillFullyVisible = false;
  4849. for (var i = 0; i < numVisiblePages; ++i) {
  4850. var page = visiblePages[i];
  4851. if (page.percent < 100) {
  4852. break;
  4853. }
  4854. if (page.id === currentId) {
  4855. stillFullyVisible = true;
  4856. break;
  4857. }
  4858. }
  4859. if (!stillFullyVisible) {
  4860. currentId = visiblePages[0].id;
  4861. }
  4862. if (!this.isInPresentationMode) {
  4863. this._setCurrentPageNumber(currentId);
  4864. }
  4865. this._updateLocation(visible.first);
  4866. this.eventBus.dispatch('updateviewarea', {
  4867. source: this,
  4868. location: this._location
  4869. });
  4870. }
  4871. }, {
  4872. key: '_setDocumentViewerElement',
  4873. get: function get() {
  4874. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this.viewer);
  4875. }
  4876. }]);
  4877. return PDFViewer;
  4878. }(_base_viewer.BaseViewer);
  4879. exports.PDFViewer = PDFViewer;
  4880. /***/ })
  4881. /******/ ]);
  4882. });
  4883. //# sourceMappingURL=pdf_viewer.js.map