I recently started developing an app with React. I am really new to JS and in general with web development, so I'll probably sound noobish :D
My goal is to download and render some pdf from some url. The main problem is that the webpage I request the pdf to runs a javascript code in order to identify me, so I cannot render directly the pdf from the url as one usually does with react-pdf. Specifically, what happens is that when I request the pdf directly from react-pdf to the url, the webpage does not manage to run its JS scripts, and so it renders another page which is different from the pdf I'd like to get. Therefore, react-pdf throws an error saying that it didn't manage to load the pdf.
As a workaround, I wrote some api using puppeteer and express that downloads the pdf from the url to some local folder. It's not really meant to be just a workaround, I would actually prefer to download the pdfs into some local folder so that I don't re-download them in case I have them already (and in my use case, it will happen a lot!). The problem, then, is that I cannot render it from the local folder using react-pdf, because I would need an import statement at the beginning of the code for something that is not there yet.
Does anybody know if there is a way, using react-pdf, to render a local pdf file without using an import statement? I read on the documentation that one can use also an input tag in the middle of the code. Specifically, among the props of the class Document, they say file "value can be a file imported using import ... from ... or from file input form element". I haven't found yet any examples online that can help me understand how to do it, and I'm quite struggling. Otherwise, can you suggest another library for rendering (local) pdfs that gives also the possibility of adding annotations quite easily?
Edit: I solved the problem in the end. I put the downloaded files to the public folder of my React project, and then I called the files with http://localhost:3000/ + file.pdf.