ken107 / read-aloud

An awesome browser extension that reads aloud webpage content with one click
https://readaloud.app
MIT License
1.36k stars 233 forks source link

Feature request: Local PDF easier loading? #330

Open samharwood opened 1 year ago

samharwood commented 1 year ago

It would be really helpful for us to be able to use ReadAloud to read exam papers if loading local PDFs files was easier.

Right now if I open a local PDF in the browser, then click ReadAloud, it shows the "Select PDF to Read Aloud" page and we have to pick the file again to load into ReadAloud. I know there are difficulties with CORS and local files. But is there any way around this? The "Allow access to file URLs" option in extensions doesn't seem to help at all (we are using Edge).

ken107 commented 1 year ago

When you open the PDF in the browser, it opens using the browser's built-in PDF viewer, which cannot be manipulated. Therefore we have to redirect to our own PDF viewer and ask the user to open the file again. I don't think a webpage can automatically access local files upon pageload, for security reasons. Even extension pages cannot load arbitrary files on the user computer either. The "Allow access to file URLs" only allows injecting script into local file already opened inside a browser tab; but still the built-in PDF viewer doesn't expose any API to javascript.

The best thing I can think of is to bookmark https://assets.lsdsoftware.com/read-aloud/pdf-viewer-2/web/readaloud.html Then go straight to that page when you need to read aloud PDFs.

samharwood commented 1 year ago

Thanks. Your suggestion is a good workaround as I can provide this as a shortcut for staff to click on.

samharwood commented 1 year ago

Our exam accounts have to have internet disabled. I requested our IT to unblock https://assets.lsdsoftware.com/read-aloud/pdf-viewer-2/web/readaloud.html to allow PDF loading but they are unable to do so. Is there some way to include the PDF viewer in the extension so it can be used to read PDF's offline? Everything else seems to work OK without internet access, except for being unable to load the PDF viewer. I've tried to see if I could build a custom version with viewer embeddded but I don't know how

ken107 commented 1 year ago

The PDF viewer is very large and hence I decided to keep it out of the deployment package. But I'll add a branch that'll have the player embedded and you can build a custom version from that. Give me a few days