Pimcore 6.3: Render Document inside a Hook/Service

System: Pimcore 6.3.6
Problem: Is there a way to access the Service::render() function inside the Backend/EventListener/Service?
Details: I need to hook into onPostUpdate inside the Pimcore Backend. So I created a EventListener. It calls a Service to push several information of the Document:


namespace AppBundle\EventListener;
...
public function onPostUpdate (ElementEventInterface $e) {
        if ($e instanceof DocumentEvent) {
            $document = $e->getDocument();
           // collecting great stuff here like URLs, title etc.
           .....
           // @TODO: Grab me the HTML of the document with ID $document->getId()

I need the HTML Code of the Rendered Page. But it does not work, neither via Document\Service nor via Twig Service Inclusion.

Thanks for any suggestions.

Document\Service::render($document) should return html code. Are you facing any error?

Thanks!
Unfortunately Pimcore\Model\Document expects a PageSnippet. So this does not work.

I fixed it like this:

use Pimcore\Model\Document\Page;
use Pimcore\Model\Document\Service;

..

Service::render(Page::getById($document->getId()));

It returns a string containing the rendered HTML Code.