
我正在使用帶有 PDF 檢視器插件的 Mozilla Firefox。該插件已與 Adobe Reader 檔案正確關聯,以便在設定中的瀏覽器中查看它們。
我希望能夠在 Firefox 中查看 PDF 檔案而不是下載它們。當 Web 伺服器指示文件Content-Type
具有application/pdf
.但是,某些 Web 伺服器Content-Type
為 PDF 提供其他 s,例如application/octet-stream
. (看這個 PDF 與非 pdf 一起提供的範例Content-Type
.)
我看過Firefox 的 MimeTypes.rdf 文件,而且它似乎只支援基於非 Internet 檔案的檔案副檔名的地圖應用程式。 (看起來它只用於Content-Type
映射基於 Internet 的文件。)
我怎麼才能讓 Firefox 查看全部瀏覽器中的 PDF 文檔,而不僅僅是帶有application/pdf
Content-Type
? 的文檔
答案1
Firefox 沒有內容檢查程式碼(例如linuxfile
指令)來偵測實際內容類型並依賴標頭Content-Type
。
解決方法:mozplugger
擴展
看man 7 mozplugger
:
extensions This is a comma separated list of extensions that should be associated with this particular mime type. The exten‐ sions are only used when a web server does not report what type of file it is, or when loading files directly from disk.
解決方法:人機交互
儲存檔案並在檔案總管中開啟它;-)
解決方法:配置錯誤
另一種解決方法是破解mimeTypes.rdf
並分配application/octet-stream
與 相同的值application/pdf
。
我不建議這種解決方法。
答案2
您可以使用強制內容類型具有錯誤回應標頭的 pdf 檔案的副檔名Content-Type
。
例如,如果 Web 伺服器提供,Content-Type: application/octet-stream
您可以新增規則以將其轉換為Content-Type: application/pdf
基於 pdf 檔案 url,如下所示: