Make a PDF attachment to the article immediately after clicking the save button

Hello, can anybody help me. I want to automatically export page content in pdf in attachment after page changes (page saved). Is it possible?

Are you a java developer? :slight_smile: (asking since you’ll need that skill).

In short the answer is not.

Longer answer:

  • Basically you need to write an Event Listener in java and listen to the DocumentUpdatedEvent. See
  • Then you need to call the PDF exporter code (PdfExportImpl) to perform the export (void exportToPDF(XWikiDocument doc, OutputStream out, XWikiContext context) throws XWikiException;).
  • Then use the XWikiAttachment object to save/update an existing attachment or a new one and pipe the PDF export stream to it, and save the document.
1 Like

Note that this would make the save quite slow.

Thanks, may be i will try later. I haven’t good JS skills but i know some basics. If i will make this code snippet, then i will share code here.