I’m working on a project where I need to extract text along with its coordinates from a PDF document using JavaScript. I’m familiar with PDF.js, but I’m unsure how to use it to get the coordinates of the text. I’m also open to using other JavaScript libraries if they provide a more straightforward way to achieve this.
Here are the specifics of what I’m trying to do:
Extract text from a PDF page.
Obtain the coordinates (x, y) for each piece of text.
On click of paragraph, show action menu for that para and add a background color to the paragraph.
It would be great if i can get an examples of how to extract text with coordinates using PDF.js or any other JavaScript library.