@@ -9,7 +9,7 @@ var queryParams = query ? JSON.parse('{' + query.split('&').map(function (a) {
99var url = queryParams . file || '../../test/pdfs/liveprogramming.pdf' ;
1010var scale = + queryParams . scale || 1.5 ;
1111
12- function renderDocument ( pdf ) {
12+ function renderDocument ( pdf , svgLib ) {
1313 var numPages = pdf . numPages ;
1414 // Using promise to fetch the page
1515
@@ -37,7 +37,7 @@ function renderDocument(pdf) {
3737 anchor . appendChild ( container ) ;
3838
3939 return page . getOperatorList ( ) . then ( function ( opList ) {
40- var svgGfx = new PDFJS . SVGGraphics ( page . commonObjs , page . objs ) ;
40+ var svgGfx = new svgLib . SVGGraphics ( page . commonObjs , page . objs ) ;
4141 return svgGfx . getSVG ( opList , viewport ) . then ( function ( svg ) {
4242 container . appendChild ( svg ) ;
4343 } ) ;
@@ -49,14 +49,17 @@ function renderDocument(pdf) {
4949
5050// In production, the bundled pdf.js shall be used instead of RequireJS.
5151require . config ( { paths : { 'pdfjs' : '../../src' } } ) ;
52- require ( [ 'pdfjs/display/api' , 'pdfjs/display/svg' ] , function ( api , svg ) {
52+ require ( [ 'pdfjs/display/api' , 'pdfjs/display/svg' , 'pdfjs/display/global' ] ,
53+ function ( api , svg , global ) {
5354 // In production, change this to point to the built `pdf.worker.js` file.
54- PDFJS . workerSrc = '../../src/worker_loader.js' ;
55+ global . PDFJS . workerSrc = '../../src/worker_loader.js' ;
5556
5657 // In production, change this to point to where the cMaps are placed.
57- PDFJS . cMapUrl = '../../external/bcmaps/' ;
58- PDFJS . cMapPacked = true ;
58+ global . PDFJS . cMapUrl = '../../external/bcmaps/' ;
59+ global . PDFJS . cMapPacked = true ;
5960
6061 // Fetch the PDF document from the URL using promises.
61- api . getDocument ( url ) . then ( renderDocument ) ;
62+ api . getDocument ( url ) . then ( function ( doc ) {
63+ renderDocument ( doc , svg ) ;
64+ } ) ;
6265} ) ;
0 commit comments