leafwiki icon indicating copy to clipboard operation
leafwiki copied to clipboard

PDF Embedding

Open lboehm opened this issue 2 months ago • 3 comments

Problem / use case

LeafWiki has no way to show a PDF inline on a page today - the only options are a plain download link, or (for images/audio/video) an inline preview. Teams that keep spec sheets, datasheets, or scanned documents alongside their wiki pages have to leave the page to view them, which breaks the "everything in one place" value of a wiki.

Proposed behavior

  • Extend the existing markdown image syntax to also embed PDFs: ![Manual](file.pdf) renders the PDF inline as an iframe (using the browser's built-in PDF viewer) instead of a broken image icon, with an "open in new tab" fallback link underneath.
  • A #page=N fragment (![Manual](file.pdf#page=3)) opens the embed on that page, using the standard PDF "open parameters" already supported by Chrome/Firefox/Edge's built-in viewer - no extra code needed beyond passing the fragment through untouched.
  • The Asset Manager gets an "Insert PDF" action (embed) next to the existing "Insert PDF link" (plain download link), mirroring how images work today.
  • Pasting (Ctrl+V) or dragging a PDF file directly onto the editor uploads it and inserts the embed markdown automatically, same as it already works for images. Drag-and-drop is scoped to PDFs only - every other file type keeps its current (native browser) drop behavior unchanged.
  • PDFs still also show up in the page's "Attachments" panel, same as audio/video today.

Is this ready to be implemented, or does it need discussion first?

Implemented on branch feat/pdf-embed (https://github.com/lboehm/leafwiki/tree/feat/pdf-embed), reusing the existing markdown image syntax and the same asset-resolution/cache-busting pipeline that already backs images - no new custom syntax, no PDF.js dependency, no backend changes needed (uploads already accepted any file type).

This is a proposal - happy to adjust the approach if maintainers see it differently or want a different direction.

lboehm avatar Sep 22 '26 08:09 lboehm

Hi @lboehm,

Could you create a PR? I think it is a nice idea.

perber avatar Sep 22 '26 08:09 perber

I've created the PR. It's my first one in this project, please let me know if I could improve something.

lboehm avatar Sep 22 '26 08:09 lboehm

Shipped in v0.14.0 via #1582 (follow-ups #1633, #1637).

perber avatar Oct 09 '26 15:10 perber