sigrlami
sigrlami

Reputation: 1832

How to show pdf inside elm application?

I have an Elm web application, in a form of SPA and I need to integrate pdf preview functionality.

How can I show pdf file inside Elm application and track that user actually scrolled it to the end?

Upvotes: 1

Views: 468

Answers (1)

Mark Bolusmjak
Mark Bolusmjak

Reputation: 24399

Option 1 is to use a pre-existing pure Elm solution. Searching here https://package.elm-lang.org I find nothing.
Option 2 is to code something from scratch. You probably don't want to do this.

The last option, and it's the best one, is to use "custom elements" with a 3rd party javascript solution, like so:

  1. find a nice Javascript PDF viewer. There seem to be a few out there.
  2. Learn about custom elements. Start here https://guide.elm-lang.org/interop/custom_elements.html
  3. create a custom element like <my-pdf-viewer> complete with events.
  4. in Elm, render the custom element via https://package.elm-lang.org/packages/elm/html/latest/Html#node and listen for your custom events via https://package.elm-lang.org/packages/elm/html/latest/Html-Events#on

Upvotes: 7

Related Questions