pdfjs not working on xampp server but works on node server

31 Views Asked by At

I am trying to integrate pdfjs into my project and while development, when the root is in xampp server I am getting error.

But when I run on node server (live-server), I don't get any error

code

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <base href="/">
    <style>
        body{
            padding:0;
            margin:0;
        }
    </style>
</head>

<body>

    <!-- 
        - not working and getting erros as shown below
        - the xampp path is localhost/silicon-craft-2/slide
     -->
    <!-- <iframe src="http://localhost/silicon-craft-2/slide/pdfjs/web/viewer.html?file=http://localhost/silicon-craft-2/slide/assets/presentation.pdf" frameborder="0" width="100%" height="600px"></iframe> -->
    
    <!-- 
        - below code is executed with node package live server with root as /
     -->


    <iframe src="http://127.0.0.1:8080/pdfjs/web/viewer.html?file=http://127.0.0.1:8080/assets/presentation.pdf" frameborder="0" width="100%" height="600px"></iframe>


</body>

</html>

I understand the error is on the path to the root. It might work once its moved to production. But for development how to override this error.

Error Image

enter image description here

0

There are 0 best solutions below