Wednesday, April 20, 2011

In a firefox extension how to save a copy of a pdf opened in the browser window

I have a Firefox extension and in some cases when a user navigates to a PDF I'd like to save a copy of the file. This is easy when the PDF is downloaded (as I can use nsIObserverService to get the file), but when the PDF is opened in the browser using the Adobe Reader plugin I can't see how to get the file without downloading it again. Any ideas?

The plugin or firefox seems to wrap the pdf in html that contains a single EMBED tag with the pdf. So I can get the embedded object via doc.embeds[0] but don't know if there's any available interface to do anything with that.

An alternative would be to use something like nsIObserverService to notice when a file has been retrieved for viewing - but I don't know if that's possible?

I don't want to simply get the url and re-retrieve it will sometimes no longer be available, having been served from a web app.

thanks!

From stackoverflow
  • If the pdf is opened using the Adobe Reader plugin you can simply click on the Save icon on the reader tool bar. That is the easiest way.

    rwmnau : I think the OP means that his extension will automatically save the file, without any user interaction.

0 comments:

Post a Comment