Made an Obsidian Plugin

For more than five years I’ve moved all my notes and documents – personal and professional – into Obsidian, a super-powerful app for organising and maintaining notes using markdown. I’m quite fanatical about the app. And now, I’ve written a plugin that I’ve just submitted be included in the Obsidian Community Plugins directory. It’s my first-ever bit of coding that I’ve felt I should share.

I moved to Obsidian after using OneNote from the year 2000 to keep my resources and notes as a teacher. I was an early adopter of OneNote when Microsoft first released its tablet pcs. Over the years I accumulated hundreds of “notebooks” filled with handwrtten notes, PDFs, images, audio files, videos. Then in about 2018 I tried to export one of my notebooks into another app and found that it was pretty much impossible to do so. That sent me down a rabbit hole of realising how trapped I’d let myself become by propriety software – including ones that claimed interoperability or easy export but didn’t make it at all possible. (I’d used Evernote and Apple Notes as well for personal stuff – but they were, admittedly easier to export from.) I learned that keeping notes in text files was about the most reliable and so, after trying out a range of apps, settled on Obsidian which was gaining popularity due to the ways in which it could be enhanced through plugins and themes.

My Obsidian vaults (the name given to the collections of notes made by the app) are synced between laptops, ipads and my phone using Syncthing which means I can acces and add to them anywhere. Because I keep my vaults synced like this, I’ve learned to keep my vaults lightweight and containing only text files. Which means that I self-host other media like images, PDFs and audio files separately. (I used to do this using OneDrive and the webhost here where I maintain my blog but now self-host off a server in my house.) Everything works excellently…

… Except that Obsidian embeds PDFs in notes only if they’re kept in the vault. There are workarounds that do things like creating virtual folders and symlinks – but they still require copying the PDFs to a local device. Images aren’t treated like that: you can keep them in your vault or you can embed them from whichever website they’re hosted. I embed lots of images and have tried to embed PDFs over the years with no success. I’ve had lots of conversations online with other Obsidian users who’ve told me that it’s not possible to embed a PDF from an external source. Stubbornly, I just couldn’t understand why it wasn’t possible if other media – including audio and video files – could. It was something that I just couldn’t let go.

So, after installing Paperless-NGX as a repository for all my documents in PDF, I decided to work on a way of embedding a PDF in an Obsidian note. I have a rudimentary knowledge of javascript, which is the language used for Obsidian plugins and began to write the code. Of course, it didn’t work. So I asked some AI tools for assistance in checking my code and suggesting improvements. The AIs were useful in picking out areas and suggesting ways that the plugin could be improved – though, several times, they sent me off on the wrong track. Eventually, the plugin sort of worked… until it sort of didn’t. I found that I needed to make sure that it could work on iOS – and that threw up a massive security issue because Apple don’t seem to like PDFs being embedded on mobile devices. Some sort of security issue that I don’t understand. Then, with a bit of recoding, I managed to get it working across all platforms I had access to: Windows, OSX, Linux and iOS. A little more recoding to enable PDFs to be embedded from local files on a device external to the Obsidian folder and it was pretty much finished.

So, what does my plugin, External PDF, actually do? It’s very simple and fills a hole in what I think should be basic functionality in Obsidian. It lets you embed a PDF hosted on a website in a note without having to download the PDF and save it in your vault. In your note, you just need to add something like this (with your link to the PDF document online, of course):

```external-pdf
https://example.com/document.pdf
```

…and the PDF will be visible in your note, embeded in a reader frame. There are options to include title, sizes and the ability to embed PDF files kept locally on your computer but not in your Obsidian vault. Even if no one else in the world is at all interested in embedding PDFs like this, it is something I’ve wanted to be able to do for a very long time. And now I can.

Just in case someone else is interested in this, I’ve put my plugin up on GitHub and submitted it to Obsidian to be included in their community plugins repo. While I realise this isn’t a big deal for someone who programs, it’s the first time I’ve made something like this that works and the first time in a long, long time that I’ve felt I’ve improved my tech knowledge.