Adding locally stored PDF from browser

Is anyone aware of a way to get the Zotero browser extension to recognize locally stored PDFs as PDFs instead of as web pages?

My problem is that some sites default to downloading PDFs rather than displaying them directly in new browser tabs. However, when I click on the downloaded PDF and open it in a new Chromium Edge tab (Windows 10), the Zotero extension doesn't recognize the file as a PDF. Instead, it saves it to Zotero as a web page, with no attachment.

Any ideas?
  • You can just drag downloaded PDFs to Zotero from your file system.
    Add-ons typically don't have access to local files loaded in the browser for security reasons, so pretty sure what you're asking can't be done.
  • Yeah, dragging and dropping downloaded files is what I end up doing. But that involves multiple clicks, drags, sometimes a window resize, etc., as opposed to what could be just a single click with the Zotero extension button. Sometimes I copy the URL for the local file path and then paste that in the "Store copy of file" dialogue to add it with less mouse clicks, but that doesn't work with a Mac.

    I didn't realize that the extension couldn't access a local file, but I guess that makes sense.
  • edited July 14, 2020
    1) If there's a site that you know does this, you can drag the link to Zotero instead of clicking it.

    2) Not specific to Zotero in any way, but note that you never need to resize windows for something like this. You can click and drag the file and then use Cmd-Tab to bring Zotero (or any app) to the front, and then drop the file in. See Switching Between Programs for the basics of switching between programs efficiently. (The important point here is just that you can use those techniques in combination with dragging.)

    3) A future version of Zotero will allow you to drag files to the Dock icon as well as open PDFs via Zotero and treat those as if you had dragged them to the current library.
  • Especially since Firefox now defaults to opening downloaded PDFs in Browser it would be nice and save a few clicks if the Zotero connector recognized the PDF as such, however.
  • @samvines: This may be a misunderstanding. If you just click on a regular PDF link on the web, Firefox will display the PDF by default, and you can save those to Zotero by clicking the save button.

    This thread is about PDFs you've already downloaded to disk (shown with file:// URLs in Firefox), and as far as I know Firefox doesn't associate itself with those on any platform (as Edge does on Windows). Those can't currently be saved via the Zotero Connector for technical reasons.
  • edited August 6, 2020
    @dstillman The update to Firefox 78 changed that behavior; when clicking on a PDF link Firefox now offers to open it inside the browser instead of the system's PDF viewer (the previous default). PFDs are then displayed with the file://URL, because they are downloaded to disk before they are displayed.
  • edited August 6, 2020
    @samvimes: No, that's some sort of misconfiguration on your end. Firefox has defaulted to previewing PDFs in the browser — at their original HTTP URLs, without prompting — for years, and it absolutely does not download files and display them at file:// URLs by default. If you're having trouble with that, check your Firefox settings and post to a Firefox forum if you still have questions.
  • @dstillman Sorry, I think there's a misunderstanding here. Firefox has always opened PDFs in browser, but some websites link to PDFs with the download attribute (some Google results, for example). This prompts the "Open with..."-dialogue in Firefox, which has been modified in Firefox 78 (see https://www.researchsnipers.com/now-you-can-open-pdf-files-with-firefox-browser/). I am referring to this new option, sorry if I haven't made that clear!
  • edited August 6, 2020
    Ah, OK — Mozilla doesn't seem to have even documented that change.

    To be clear, this should only apply to a small number of PDFs — sites have to go out of their way to force PDFs to download, and the vast majority don't do so, so most PDFs should be previewed in the browser at their HTTP URLs.

    A browser extension could trivially fix this. E.g., here's one (untested) that rewrites the Content-Disposition header sent by the server, which prevents this. That wouldn't address the 'download' attribute on links, which is another method, though there might be another extension that does that (and that method is less common — e.g., any from Google results would have to be Content-Disposition, because 'download' is on the link and Google doesn't do this themselves).
  • After some years I've finally found a nice solution for the problem: In about:config set browser.download.open_pdf_attachments_inline to true. Afterwards Firefox will not clutter the Download folder with pdfs and importing pdfs into Zoero is a bit easier.
Sign In or Register to comment.