為了改善您的使用體驗,本網站正在進行維護,部分功能暫時無法使用。若本站的文件無法解決您的問題,想要向社群發問的話,請到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 發問,我們的社群成員將很快會回覆您的疑問。

搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

PDFs are opening in browser AND downloading

more options

In my Firefox settings, I have PDF files set to "Open in Firefox".

When I click on a PDF file, Firefox DOES open the PDF in a new browser tab, but the PDF ALSO downloads to my desktop (both!). How can I stop it from downloading?

In my Firefox settings, I have PDF files set to "Open in Firefox". When I click on a PDF file, Firefox DOES open the PDF in a new browser tab, but the PDF ALSO downloads to my desktop (both!). How can I stop it from downloading?

由 gtg254k 於 修改

被選擇的解決方法

If you don't want the PDF in your Temp folder, either, Firefox 103 added a new option to store it in the browser cache.

(3) New Content-Disposition Override

When a server sends a PDF, it can optionally send a Content-Disposition header (MDN). This header can indicate either "inline" or "attachment".

  • "inline" refers to displaying in the browser
  • "attachment" refers to downloading

This is invisible to you but explains why some PDFs open normally with their web address (inline) and some save to disk and open in a new tab with a file:/// address (attachment) after being saved to disk.

GOOD NEWS: Firefox 103 now has a new feature to override Content-Disposition: attachment for PDFs, making Firefox treat them all as web content (inline). If you prefer to use Firefox as your PDF viewer, then this should be helpful:

(a) In a new tab, type or paste about:config in the address bar and press Enter/Return. Click the button accepting the risk.

More info on about:config: Configuration Editor for Firefox. The moderators would like us to remind you that changes made through this back door aren't fully supported and aren't guaranteed to continue working in the future. I'm using this so I feel comfortable mentioning it.

(b) In the search box in the page, type or paste browser.download.open_pdf_attachments_inline and pause while the list is filtered

(c) Double-click the preference to switch the value from false to true

Success?

從原來的回覆中察看解決方案 👍 2

所有回覆 (3)

more options

PDF files need to be downloaded for Firefox to be able to read them for the PDF viewer.

more options

Firefox 98 made a lot of changes to how PDFs open. The two big ones are:

(1) Skipping the download dialog

Firefox 97 and earlier would present a download dialog if the server tried to bypass the viewer by forcing a download (Content-Disposition: attachment). If you have "Open in Firefox", Firefox now skips the dialog and behaves as though you had clicked "Open with Firefox" in that dialog. In other words, it saves the file to disk and then opens it.

(2) Saving files in the "Save files to" folder instead of your Windows Temp folder

Firefox 98 changed from saving downloads in the Windows Temp folder for "Open with [relevant application]" or "Use [relevant application]" to saving them in your default downloads folder (the one next to "Save files to" on the Settings page). It's not possible to pass a file to an application without saving it somewhere.

Firefox 102 added a hidden setting to roll back that change. Here's how you access it:

(a) In a new tab, type or paste about:config in the address bar and press Enter/Return. Click the button accepting the risk.

More info on about:config: Configuration Editor for Firefox. The moderators would like us to remind you that changes made through this back door aren't fully supported and aren't guaranteed to continue working in the future.

(b) In the search box in the page, type or paste browser.download.start_downloads_in_tmp_dir and pause while the list is filtered

(c) Double-click the preference to switch the value from false to true

more options

選擇的解決方法

If you don't want the PDF in your Temp folder, either, Firefox 103 added a new option to store it in the browser cache.

(3) New Content-Disposition Override

When a server sends a PDF, it can optionally send a Content-Disposition header (MDN). This header can indicate either "inline" or "attachment".

  • "inline" refers to displaying in the browser
  • "attachment" refers to downloading

This is invisible to you but explains why some PDFs open normally with their web address (inline) and some save to disk and open in a new tab with a file:/// address (attachment) after being saved to disk.

GOOD NEWS: Firefox 103 now has a new feature to override Content-Disposition: attachment for PDFs, making Firefox treat them all as web content (inline). If you prefer to use Firefox as your PDF viewer, then this should be helpful:

(a) In a new tab, type or paste about:config in the address bar and press Enter/Return. Click the button accepting the risk.

More info on about:config: Configuration Editor for Firefox. The moderators would like us to remind you that changes made through this back door aren't fully supported and aren't guaranteed to continue working in the future. I'm using this so I feel comfortable mentioning it.

(b) In the search box in the page, type or paste browser.download.open_pdf_attachments_inline and pause while the list is filtered

(c) Double-click the preference to switch the value from false to true

Success?