Inline PDF Previews

What do you mean? This is a desktop component.

Just to clarify - I know inline PDF previews are still supported in Discourse.

My question is specifically about the theme component itself - it currently throws deprecation warnings in the console on recent Discourse versions.

Would this need a PR to update the deprecated API usage (e.g. plugin API / Ember hooks), or is there already work underway to modernize it?

2 Likes

Since it’s marked official , it’s reasonable to assume that it’ll be updated before it’s too late.

4 Likes

A post was split to a new topic: Gating system similar to Scribd

Yeah, my feature PR above fixes the deprecated API. However, it needs more work, and I’ve been too busy to look at it again.

1 Like

I’m disappointed that the viewing of a pdf on a mobile device is not permitted. I’m hoping to migrate my phpBB site to Discourse, because phpBB is clunky - but, I’ve hacked a feature into my board using pdf.js that permits me to embed pdfs. And pdf.js permits you to zoom and pan - while it’s not as robust as on the desktop, it’s useful in the garage to scan a manual without having to run back into the house. This example is not that of a manual, but demonstrates the principle: Bulletin #361 - A Diesel in America

Facebook is eating my lunch, and primarily with mobile devices - I’m hoping to win users back with a Discourse integration. But losing pdf on the handheld is not a win for me.

-Dan

3 Likes

It appears PDFs aren’t rendering in Brave on Mac OS (at least on 25 up thru 26.2)…

1 Like

Console throws discourse.static-viewport-initialization deprecation warning.

log_manager.js:98 [Gemini Nexus] Background Service Worker Started
index.js:4  Gemini Nexus v4.2.3 Ready 
runtime.ts:81 DEPRECATION: Importing `inject` from `@ember/service` is deprecated. Please import `service` instead. [deprecation id: importing-inject-from-ember-service] This will be removed in ember-source 7.0.0. See https://deprecations.emberjs.com/id/importing-inject-from-ember-service for more details.
(anonymous) @ deprecate.js:72
s.<computed> @ handlers.js:10
(anonymous) @ deprecate.js:108
s.<computed> @ handlers.js:10
(anonymous) @ deprecate.js:116
s.<computed> @ handlers.js:10
(anonymous) @ index.js:75
(anonymous) @ index.js:110
s.<computed> @ handlers.js:10
(anonymous) @ index.js:115
s.<computed> @ handlers.js:10
r @ handlers.js:19
l @ deprecate.js:189
k @ index.js:31
p @ index.js:126
o @ index.js:31
n @ runtime.ts:81
<static_initializer> @ external-link-confirm.gjs:18
(anonymous) @ external-link-confirm.gjs:18
app.js:297 ℹ️ Discourse v2026.1.0-latest — https://github.com/discourse/discourse/commits/1c90b0dd85 — Ember v6.6.0
deprecated.js:52 DEPRECATION NOTICE: Accessing `site.mobileView` or `site.desktopView` during the site initialization can lead to errors and inconsistencies when the browser window is resized. Please move these checks to a component, transformer, or API callback that executes during page rendering. [deprecated since Discourse 3.5.0.beta9-dev] [deprecation id: discourse.static-viewport-initialization] [info: https://meta.discourse.org/t/367810]
d @ deprecated.js:52
get mobileView @ site.js:123
(anonymous) @ compat.js:22
X @ index.js:416
i.get @ compat.js:21
(anonymous) @ initialize-for-pdf-preview.js:10
eH @ plugin-api.gjs:3363
initialize @ initialize-for-pdf-preview.js:9
i.initialize @ app.js:265
(anonymous) @ index.js:379
e.each @ index.js:183
e.walk @ index.js:112
e.each @ index.js:59
e.topsort @ index.js:65
_runInitializer @ index.js:392
runInstanceInitializers @ index.js:377
_bootSync @ instance.js:116
didBecomeReady @ index.js:784
invoke @ index.js:262
flush @ index.js:180
flush @ index.js:334
_end @ index.js:762
_boundAutorunEnd @ index.js:499
Promise.then
(anonymous) @ index.js:18
flush @ index.js:29
_scheduleAutorun @ index.js:928
_ensureInstance @ index.js:919
schedule @ index.js:618
f @ index.js:343
waitForDOMReady @ index.js:512
init @ index.js:412
_ @ core.js:97
create @ core.js:599
(anonymous) @ start-app.js:18
await in (anonymous)
(anonymous) @ discourse-boot.js:13
(anonymous) @ discourse-boot.js:1
loader.js:46 Lazy dependencies loading...

I submitted a PR adding mobile support and PDF.js integration to this component
5+ weeks ago, but haven’t received any feedback yet. Since others might find it
useful, I’m sharing my enhanced fork:

https://github.com/shortmort37/discourse-pdf-previews

Key improvements:

  • Mobile device support (removes the mobile block)
  • PDF.js rendering with page navigation and zoom controls
  • Thumbnail previews in “New Tab” mode
  • Works with PDFs lacking .attachment class (great for migrations)
  • Pinch-to-zoom on mobile

I’ve been running this on 59plymouth.net for 2+ months with
converted phpBB content - works great on both desktop and mobile.

Installation: Admin → Appearance → Themes → Install from Git → paste the URL above

PR is still open if the maintainers want to review: Add PDF.js integration with mobile support by shortmort37 · Pull Request #49 · discourse/discourse-pdf-previews · GitHub

6 Likes

Hey guys,

I’m using the component and just noticed this when logged in as admin:
image

2 Likes

That PR description on github looks fantastic! :star_struck: I also rely on this component for numerous things and on numerous discourse sites, and would love for it to work on mobile as well as it does on desktop. Hope the PR can be looked at by the team soon.

(Also seeing the admin notice, and disabling the component for now)

on 2026.7.0-latest +288

github.com/discourse/discourse-pdf-previews

About License

Checked for updates, last checked: 9 mins ago


removed Default so there’s no themes where this component is installed on

1 Like

@tpetrov this is now fixed :+1:

5 Likes

Hi @tobiaseigen — the admin notice you saw is almost certainly the deprecation warning behind the discussion above; it comes from the older mobile-detection call in the original component. My fork takes a different approach: rather than patching that call, it removes the mobile restriction altogether (the whole point was to let PDFs render on mobile), so that deprecated code path is gone entirely. I’ve since merged the latest upstream changes into my branch as well, so it’s current.

If you’d like to try it, it installs from git at:
https://github.com/shortmort37/discourse-pdf-previews
— using the feature/pdfjs-mobile-support branch (there’s a branch field under the “advanced” option in the install dialog).

One tip from my own testing: after installing, run “Check for updates” on the component once and then hard-refresh — Discourse caches the compiled theme JS, and that step makes sure you’re running the current code.

Fair warning that this is my personal fork with added features (PDF.js rendering, page navigation, zoom, thumbnails in new-tab mode) rather than the official component, and my PR to fold these changes upstream (#49) is still open and awaiting review. Happy to answer any questions.