2

I am following the approach of here. The problem is that all the pages are in first canvas. This is because I have only one canvas and I am not sure how I can generate more canvas one after other?

 function handlePages(page)
        {
            var viewport = page.getViewport(canvas.width / page.getViewport(1.0).width);
            var ctx = canvas.getContext('2d');

            canvas.height = viewport.height;
            canvas.width = viewport.width;

            page.render({ canvasContext: ctx, viewport: viewport });

            //Add it to the web page
            div.appendChild( canvas);
                //Move to next page
                currPage++;
                if ( $scope.pdfDoc !== null && currPage <= numPages )
                {
                    $scope.pdfDoc.getPage( currPage ).then( handlePages );
                }



        }
Community
  • 1
  • 1
Sara
  • 2,308
  • 11
  • 50
  • 76
  • you cut out part of the code from the linked answer that you took this from. notice the `document.createElement( "canvas" )`. That creates a new canvas for every page. – Don Rhummy Feb 04 '15 at 06:23

1 Answers1

2

you cut out part of the code from the linked answer that you took this from. notice the document.createElement( "canvas" ). That creates a new canvas for every page.

Don Rhummy
  • 24,730
  • 42
  • 175
  • 330