I would like to write a Chrome extension that kicks in whehever a PDF is is displayed (https://stackoverflow.com/a/21042958/353337 shows you how to detect the MIME type, for example), and compute a hash of the PDF file. How can I retrieve the PDF in JS to work with it?
Asked
Active
Viewed 58 times
0
-
1At present, you have no other option besides requesting the PDF again, and hoping that the PDF is served from cache. Why do you want to compute the hash? – Rob W Apr 27 '15 at 10:40
-
Jup, I thought about the cache too, to hopefully refetching won't hurt too much. The hash is to check weather the PDF exists in a certain database. – Nico Schlömer Apr 27 '15 at 11:00
-
You could trade off accuracy for performance by using a Range request to only fetch the first X bytes of the PDF file. This would only work if you still have to build the database from scratch though. – Rob W Apr 27 '15 at 11:04