Skip to content
Advertisement

Select Text within ’embed’ for pdf document

I am attempted to scrape information off a website which apparently uses an ’embed’ to display a pdf window. The code is very simple and I’ve found a method for sending the information.

If I ‘ctrl + a’ the pdf window, it will select everything. At which point, I can now send the information as needed through a message.

My problem is, that I need a method to select and set the range on the information automatically. Preferably not manually.

The html is pretty easy:

JavaScript

That really is all of it. The stuff is apparently inside the embed. As I said, I can ‘ctrl + a’ and highlight everything and get the info sent as needed, but I can’t seem to figure out how to automatically select the text inside the embed.

My current code is:

JavaScript

Any ideas?

Advertisement

Answer

document.querySelector(’embed’).postMessage({type: ‘selectAll’});

This works perfectly… You put it into the content script.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement