'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 1:[1]

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"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 M. Korichi