Custom View that Uses the PDF View

I develop a plugin for Supernote that has about 5k downloads: Plugins - Obsidian

My core question: Is there an API to extend the Obsidian PDF View to convert from a different file format to PDF in-memory?

Context

Supernote is a brand of eink tablet. And a major feature of the plugin is enabling people to preview the .note files from a Supernote device into an HTML view inside of Obsidian.

However, I now have a feature to create a PDF from the .note file. Which got me thinking can I replace my SupernoteView (supernote-obsidian-plugin/src/main.ts at main · philips/supernote-obsidian-plugin · GitHub) with a view that utilizes the builtin PDF view? The trick is I need to hook the file load to go through my PDF conversion first.

So, is there an API to extend the Obsidian PDF View to convert from a different file format to PDF in-memory?

This is my GitHub issue on this: research: Use PDF as Default Note View · Issue #59 · philips/supernote-obsidian-plugin · GitHub

I think you can split into steps

  1. Generate temp.pdf in your SupernoteView
  2. Open generated temp.pdf
  3. Once the view with temp.pdf is closed, remove the generated file

Where can a plugin safely put temporary files? I hadn’t considered this but I also thought writing a temporary file into a vault would be bad practice.

Also, I think the downside of this is that I have particular commands that I only want running on my note view (like convert to Markdown). And with my current understanding of the plugin API I don’t know if I can do that without also controlling my own view class.

Temporary files could be put

  1. As normal files in the vault
  2. As .hidden-dot-file.pdf in the vault
  3. Inside your this.pluginDir, i.e. vault/.obsidian/plugins/plugin-id/temp.pdf

However, you need to see if opening PDF works equally fine in those scenarios

If you need a full control over the view, you might need a more sophisticated approach that would require digging into Obsidian internals