renedering pdf in canvas in laravel vue .. using pdf.js

49 Views Asked by At

the pdf file doesnt render although i get the number of pages ; i tried in index.html and jsfile and still doesnt render in canvas element

<canvas id="mycanvas" ></canvas>

pdfjsLib.getDocument(url).promise.then(pdfD => { pdfDoc = pdfD;

console.log(pdfD.\_pdfInfo.numPages);
console.log(pdfD.numPages);
console.log(pdfD);

    pdfD.getPage(1).then(page=\>{
       var mycanvas = document.querySelector('#mycanvasx');
        var context = mycanvas.getContext("2d");

        var viewport  = page.getViewport(1);
        mycanvas.width = viewport.width;
        mycanvas.height = viewport.height;

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

    });

i need an answer for this problem

0

There are 0 best solutions below