1

I have a pdf file stored on my node.js/express server and I want to display it in my html page.

In my controller I have the following code : CONTROLLER

let filePath = process.env.uploads_dir+'/todolists/'+req.params.clid+'/'+req.params.siid+'/'+req.params.fileName;
res.download(filePath);

Then, in my html (pug) page I just have this code : (src contains the route that calls the controller) : PUG

block prepend body
body#page-top.fixed-nav.sticky-footer.bg-dark
    .content-wrapper
        .container-fluid
            embed(width="400", height="400", src="/download/clientName/filename.pdf", type="application/pdf")

The pdf viewer shows me an error "Failed to load PDF file". I have already try to use PDFObject and PDF.js but still the same problem and I have also read some questions but nothing too. QUESTIONS :

Gabriel Curinga
  • 305
  • 4
  • 20

0 Answers0