I tried to use pdfjs to render the pdf on canvas but when I see the network request the full file is downloadable. I store files on fs and path on sql db.
And also i tried read the pdf uploaded by user's and split it with hummusjs on the server then send it to the browser but this is not scalable for many files
<pre>app.get('/', (req, res) => { //hummusjs let readPdf = hum.createReader('./uploads/quote.pdf-1675405130171.pdf'); let pageCount = readPdf.getPagesCount(); writePdf = hum.createWriter('preview.pdf'); writePdf .createPDFCopyingContext(readPdf) .appendPDFPageFromPDF(0); writePdf.end() const path = './preview.pdf'; if (fs.existsSync(path)) { res.contentType("application/pdf"); fs.createReadStream(path).pipe(res) } else { res.status(500) console.log('File not found') res.send('File not found') } });
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)