0

I want to display a PDF on a canvas, without let the client know the PDF url.
I want to use pdfjs in a way that my server (nodejs) will take the PDF url and parse the PDF, then sent it to the client and the client will display the context on the canvas.
Is there a way to do that? Thanks you!

Ziv Sdeor
  • 11
  • 2
  • I think you have a valid question here but it's difficult to answer without more context https://stackoverflow.com/help/how-to-ask – ItsGeorge May 21 '20 at 16:19

1 Answers1

0

You can use a pdfreader package from NPM.

Example code:

var fs = require("fs");
fs.readFile("sample.pdf", (err, pdfBuffer) => {
  // pdfBuffer contains the file content
  new PdfReader().parseBuffer(pdfBuffer, function(err, item) {
    if (err) callback(err);
    else if (!item) callback();
    else if (item.text) console.log(item.text);
  });
});

Read more: https://www.npmjs.com/package/pdfreader

Harshal Yeole
  • 4,812
  • 1
  • 21
  • 43