PDF Embedding
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:
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=Nfragment () 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.
Hi @lboehm,
Could you create a PR? I think it is a nice idea.
I've created the PR. It's my first one in this project, please let me know if I could improve something.
Shipped in v0.14.0 via #1582 (follow-ups #1633, #1637).