PDFをダウンロードせず、ブラウザで直接開く方法

Whenever I upload a PDF, it shows in the topic as follows:

image

I’m using Inline PDF to display it in Desktop version. But, in mobile Inline PDF won’t work. Further, Google or other search engines autodetect the PDF files, but whenever the user clicks on those results, the PDF download dialogue will appear instead of opening in a tab. This is a bit unfriendly and most of the users prefer to view the PDF online instead of downloading it at a place and opening.

Is there any solution to this?

NOTE: I’ve seen this topic PDF preview instead of download, on uploaded files, but the topic ended without any relation to the original question. Hence, this new topic.

「いいね!」 7

Thanks for raising this question. I’m also curious to know the answer!

「いいね!」 3

Googleドライブに保存されたPDFを埋め込む

PDFはモバイルとデスクトップの両方に表示されます。

(iFrames内のPDFが、あらゆるデバイスでレスポンシブに表示される私の推奨方法です)

  1. 共有
  2. 共有リンクをコピー
  3. 共有リンクを新しいタブで開く
  4. 右上隅の縦3点リーダーをクリック
  5. アイテムの埋め込みを選択
  6. 表示されたiFrameコードをコピー
  7. Discourseのコンポーザー/エディターに貼り付ける

デスクトップの例…

モバイルの例…

「いいね!」 2

インラインPDFはデスクトップでも機能しません。

FileHelper.inline_images に追加すると、PDFをインラインで表示することに部分的に成功しました。

しかし、その場合、「inline=1」というパラメータが必要になります。

これは、テーマコンポーネントで追加できる可能性があります (Inline PDF Previews)。

プラグインまたは設定オプションを使用して、Discourseがcontent-disposition: inlineでPDFを提供するように切り替えるクリーンな方法を学びたいと思います。

これを目的とした小さなプラグインを作成しました。

「いいね!」 4