app/bower_components/pdf-element/main.js
/*
      * Creates a separate canvas for each page
      * Adds the eventListeneer for when the page is selected to know what page to change to 
      */
Creates a separate canvas for each page
Adds the eventListeneer for when the page is selected to know what page to change to
Creates a separate canvas for each page Adds the eventListeneer for when the page is selected to know what page to change to
function handlePages(page){
        var scale = 0.14;
        var scaleWidth = 0;
        var container = self.container;
        if(currentThis.sidebarOpen){
          scaleWidth = self.WIDTH;
        }
        else{
          scaleWidth = self.WIDTH;
        }
        scale = scaleWidth * .00035;
        var viewport = page.getViewport(scale);
        var div = document.createElement("div");
        var pageString = (page.pageIndex + 1).toString();
        var parsedFileName = pdfName.split('/').pop();
        div.style.backgroundColor = "gray";
        var click = document.querySelector('pdf-element');
        var canvas = document.createElement("canvas");
        div.appendChild(canvas);
        container.appendChild(div);
        var addPage = Polymer.dom(self.container).childNodes[page.pageIndex];
        addPage.addEventListener('click',function(){
          var nextPage = page.pageIndex + 1;
          click.sideBarClick(nextPage, currentThis.instance, currentThis);
        });
        var context = canvas.getContext('2d');
        canvas.height = viewport.height;
        canvas.width = viewport.width;
        var renderContext = {
          canvasContext: context,
          viewport: viewport
        };
        page.render(renderContext);
        currPage++;
        if ( pdfObj !== null && currPage <= numPages )
        {
            pdfObj.getPage( currPage ).then( handlePages );
        }
      }
function handlePages ( page ) { var scale = 0.14 ; var scaleWidth = 0 ; var container = self . container ; if ( currentThis . sidebarOpen ) { scaleWidth = self . WIDTH ; } else { scaleWidth = self . WIDTH ; } scale = scaleWidth * .00035 ; var viewport = page . getViewport ( scale ) ; var div = document . createElement ( "div" ) ; var pageString = ( page . pageIndex + 1 ) . toString ( ) ; var parsedFileName = pdfName . split ( '/' ) . pop ( ) ; div . style . backgroundColor = "gray" ; var click = document . querySelector ( 'pdf-element' ) ; var canvas = document . createElement ( "canvas" ) ; div . appendChild ( canvas ) ; container . appendChild ( div ) ; var addPage = Polymer . dom ( self . container ) . childNodes [ page . pageIndex ] ; addPage . addEventListener ( 'click' , function ( ) { var nextPage = page . pageIndex + 1 ; click . sideBarClick ( nextPage , currentThis . instance , currentThis ) ; } ) ; var context = canvas . getContext ( '2d' ) ; canvas . height = viewport . height ; canvas . width = viewport . width ; var renderContext = { canvasContext : context , viewport : viewport } ; page . render ( renderContext ) ; currPage ++ ; if ( pdfObj !== null && currPage <= numPages ) { pdfObj . getPage ( currPage ) . then ( handlePages ) ; } }
Creates a separate canvas for each page
 Adds the eventListeneer for when the page is selected to know what page to change to
Creates a separate canvas for each page Adds the eventListeneer for when the page is selected to know what page to change to
// Set id attribute with page-#{pdf_page_number} format //div.setAttribute("id", "page-" + pageString + "-" + parsedFileName); // This will keep positions of child elements as per our needs // Create a new Canvas element // Append Canvas within div#page-#{pdf_page_number} // Append div within div#container //Add event listener for selecting that page. // Render PDF page //Move to next page