andrexdd / discussion-export
Export any discussion as Markdown, HTML or PDF. No dependencies.
Package info
github.com/andrexdd/flarum-discussion-export
Type:flarum-extension
pkg:composer/andrexdd/discussion-export
Requires
- php: ^8.2
- flarum/core: ^2.0.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A Flarum extension. Export any discussion as Markdown, HTML, or PDF — one API call, no server-side libraries required.
The problem
Flarum has no way to get a discussion out of the browser as a file. Knowledge bases, support threads, and long-form discussions live and die inside the forum. There is no export, no download, nothing — until now.
What it does
Three endpoints, one for each format:
GET /api/discussions/{id}/export/md
GET /api/discussions/{id}/export/html
GET /api/discussions/{id}/export/pdf
Markdown downloads a plain .md file: title, author, date, and raw post content for each reply. Works in any editor or static site generator.
HTML downloads a self-contained .html file with the full rendered post content, including code blocks, quotes, images, and links — no external stylesheets or scripts. Open it in any browser, attach it to an email, drop it into a document system.
PDF opens the same HTML document in the browser with window.print() fired immediately, so the browser's own print-to-PDF produces a clean, paginated file. No server-side PDF library needed, no fonts to install, no memory spikes.
All formats include the discussion title, post count, and export timestamp in the file header.
Install
composer require andrexdd/discussion-export php flarum cache:clear
No migrations. No admin panel configuration required.
Permissions
Go to Admin → Permissions and grant Export discussions to whichever groups should be able to export. By default no group has this permission, including members — only admins can export until you change this.
Usage
Logged-in users with the discussion.export permission can call the endpoints directly, or you can link to them from anywhere:
https://your-forum.example/api/discussions/42/export/md
https://your-forum.example/api/discussions/42/export/html
https://your-forum.example/api/discussions/42/export/pdf
The md and html responses trigger a file download. The pdf response opens inline in the browser and triggers print immediately.
Compatibility
Requires flarum/core ^2.0, tested against 2.0.2. No other extension required.
License
MIT. See LICENSE.
Developed by andre.