Is it possible to interact with Obsidian (PDF export) programmatically?

What I’m trying to do

I have a vault with 100+ notes, approximately 6000-8000 words each, and I want to create PDF version of the vault regularly. What I want:

  • This process should run automatically every several days, so I want it can be called by an external script, preferably PowerShell.
  • There should be a TOC of the generated PDF.
  • The PDF produced should be properly formatted as the PDF generated by the official exporting feature.

Things I have tried

  • Better Export PDF plugin. This freezes when the notes are selected and cannot produce a PDF even after an hour.
  • Vault2Book plugin. Using this I am able to create a document referring to the notes to generate. But when using the official PDF exporting feature after that, Obsidian crashes.

I know that I can generate one PDF for each folder and then merge them together, but this will take much manual effort. Hence, I want to write a program (probably in C#) to call the Export to PDF feature for each file in background, and then combine the generated files after that.

Thanks in advance.

You need to use Pandoc to access pdf export programmatically. You can instruct Obsidian to run commands using Advanced URI or Shell commands but pdf export command itself requires configuration which you provide using the GUI. You need to emulate keyboard actions (tab, enter etc) to programmatically gain access to the native pdf export. Obsidian has incentive improving power user experience (see for example Obsidian 1.7) but we have to wait for command line printing feature (see below).

Did you find any work around to achieve a compiled pdf export? I’m facing the same issue as you.

Hi. My answer has changed a little bit. Advanced URI provides confirm parameter along with commands:

Each command URI supports the confirm parameter, which when beeing truthy (not empty and not false ) finds the first main button and clicks it. May be used for the pdf export modal to automatically press the “Export to pdf” button.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.