Search code examples
node.jsangularfile-uploadangular6pdf-viewer

Get PDF file from Nodejs and have copy in angular physical directory


I have an angular application that has a feature to render the pdf in the client side with the help of ng2-pdfviewer, that reads the file from the local directory from the client side.

Now I have an upload option which uploads the pdf files to the server and storing it in local uploads directory in the server side. Now I want to read the physical pdf file available in the server instead of downloading as blob and saving.

Does anybody have any suggestions on how to do this?


Solution

  • ng2-pdf-viewer accepts both an UInt8Array (that fits your former approach on reading from a file utilising FileReader, for instance) or a string (that can contain a remote URL) on its src parameter.

    So, as far as you have the complete URL for your target PDF, you can provide it as the source for rendering.