Export page with babylon as pdf

Hello @brianzinn ,
I want to create pdf of current page where I have 3d object with babylon-react. For this purpose I used html-to-image but its not working. Is there way to export from web pdf for babylon ? Thanks!
As I understand method toDataURL() give blank page for babylon canvas

hi @Yulian_Terletskyi - there are 2 good ways to do that.

  1. Run it server-side and print the page to PDF with puppeteer. That would work the same as for you locally to Print->PDF. You can also limit the selection to a containing HTML element, etc. Here is an example:
    brianzinn/crapdf: react pdf render puppeteer node (github.com)

  2. Another good way is just to create a screenshot of current screen in the client. Probably send that image to the server and you can initiate a PDF download with that image. If you are using Node.js then you can use pdfmake, but for other languages there are various PDF generation libraries.

Does that work?

1 Like

No, I chose other approach. For creating screenshots in Babylon, used - BABYLON.Tools.CreateScreenshotAsync, this help me to covert babylon canvas into image , thanks)

1 Like

great. if you still need a PDF you can continue the 2nd way I suggested after the screenshot. I believe there are client-side options.

Hi, there is a lib for this, jspdf. You no need server, all is frontend