Search code examples
reactjsdjangopdf.jspdf-viewer

Pdf.js with react and django


I'am trying to develope a pdf viewer with Django framework using React.js as Frontend

The problem is that the pdfviewer works perfectly on react project, but when I build it (npm run build) and copy it to the django project it doesn't work.

I think that the problems is with paths, care to suggest a method and steps to do that correctly


Solution

  • Yes, the problem was in the paths.

    Here are the steps that I have followed to make it work.

    1- copy the folder "pdfjs.2.0" into "static/js"

    2- copy all the files of the folder "pdfjs.2.0/build" into "pdfjs2.0/web"

    3- open the file "pdfjs2.0/web/viewer.html" and modify the line 36 Here is the line after modification

    4-open the file "pdfjs2.0/web/viewer.js" and modify the line 229

    Here is the line after the modification

    Value : "./pdf.worker.js"