3

Hi I'm trying to build a flipbook using 'turnjs' and 'pdf.js'. im able to build the flipbook via local pdf file and also with the online pdf url, when I tried to use pdf blob url it shows error like

Error: Access to 'blob:http://localhost:8080/41029659-ad46-4f1d-ba0a-6c874271cc38' from script denied

But when i tried to open this url using window.open im able to view the pdf in new window.

Here is my code

       //file = '1.pdf'; // it works
     file="blob:http://localhost:8080/41029659-ad46-4f1d-ba0a-6c874271cc38" // here im getting the error

 // window.open(file);  // it will shows the pdf in new window for blob url

     PDFJS.getDocument(file).then(function (doc) {
                pdfDoc = doc;
                np = (doc.numPages);

                scale = 3;
                $(".flip-book").html('')
                for (var i = 1; i <= np; i++) {
                    $(".flip-book").html($(".flip-book").html() + '<div><canvas id="canvs' + i + '" style="border: 1px solid black; width: 99.4%; height: 99.5%;"></canvas></div>');
                }

                for (var i = 1; i <= np; i++) {

                    hoja = document.getElementById('canvs' + i)
                    pdfDoc.getPage(i).then(function (page) {

                        var viewport = page.getViewport(scale);
                        hoja.height = viewport.height;
                        hoja.width = viewport.width;
                        var renderContext = {
                            canvasContext: hoja.getContext('2d'),
                            viewport: viewport
                        };
                        page.render(renderContext);
                    });


                }
                $('.flip-book').turn({
                    // Width

                    width: 922,

                    // Height

                    height: 600,

                    // Elevation

                    elevation: 50,

                    // Enable gradients

                    gradients: true,

                    // Auto center this flipbook

                    autoCenter: true

                });
            }); 
NITHIN M
  • 31
  • 2

0 Answers0