I managed to write a small plugin for this purpose:
https://github.com/thoka/discourse-send-pdf-inline