Hi,
What you are trying to achieve (rendering a page with a pluggable widget and taking a screenshot in the backend) is not directly supported in Mendix, and your observation with the PDF Generator is expected.
Why this does not work
- Mendix pages (especially with pluggable widgets / 3D rendering) rely on:
- Browser rendering
- JavaScript execution
- WebGL (for 3D)
- The PDF Generator module:
- Does not execute full JavaScript
- Does not support WebGL / 3D rendering
So:
→ Your 3D widget will not render in backend/PDF context
Important limitation
Mendix does not support headless page rendering on the server.
That means:
- You cannot open a page in backend and render it like a browser
- You cannot directly take screenshots from server-side Mendix
Option 1: Use a headless browser
Use an external service like:
- Puppeteer (Node.js)
- Playwright
Flow:
- Expose your Mendix page via a URL (with proper authentication)
- From backend (Java action or external service):
- Open page in headless browser
- Wait for rendering
- Capture screenshot
Example (concept):
await page.goto("https://your-app/page");
await page.waitForSelector("#your-3d-widget");
await page.screenshot({ path: "output.png" });
Option 2: Trigger screenshot from client - alternative
If backend is not strictly required:
- Use a JS library like:
html2canvas (limited for 3D)
Note: This may not work well for WebGL/3D content.
Option 3: Generate image from 3D engine directly
If your 3D widget uses:
Then:
renderer.domElement.toDataURL("image/png");
Send this image to backend.
Recommended Approach
Best and most reliable:
→ Headless browser (Puppeteer/Playwright)
Because:
- Fully renders JS
- Supports WebGL
- Works exactly like real browser
- Backend rendering of Mendix pages is not supported
- PDF Generator cannot render 3D widgets
- Solution:
- Use headless browser for screenshot
- Or capture from client-side canvas