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!
Asked
Active
Viewed 1,251 times
0

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 Answers
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
-
-
@ZivSdeor https://stackoverflow.com/questions/50704175/writing-text-on-image-with-npm-node-canvas-in-custom-language – Harshal Yeole May 21 '20 at 16:14