Feature Request: API for Exporting Current Document to PDF with Custom Options

To support plugin development, it would be valuable if Obsidian could provide an API for exporting the current document to PDF, with options for custom CSS. I’m developing a plugin to allow the same note to be exported as PDF with different CSS styles applied. To ensure compatibility with other plugins affecting rendering, I aim to directly call Obsidian’s native “Export to PDF…” feature rather than relying on Pandoc.

Proposed Features:

  • API Command: Add exportToPDF() to programmatically export the current document to PDF.

Parameters:

  • Output Path: Specify export location and file name.
  • CSS Support: Allow specifying a CSS file for custom styling.
  • Page Layout: Options for page size (A4, Letter, etc.) and orientation.
  • Include Options: Control over headers, footers, margins, and more.

It would be greatly appreciated if the team could consider adding such an API to support plugin development and further enhance Obsidian’s automation and extensibility.

2 Likes