Open embed pdf inside babylonjs

Hello,

Please i need to open a pdf when i click button inside babylonjs , i am using window.open but it open a new window . There is any way to open it embed inside babylonjs without leaving the page ?

Thanks a lots !!

One option would render the PDF to a canvas, and then use this canvas as a texture inside Babylon! This tutorial goes on rendering a PDF to a canvas: Rendering PDF Files in the Browser with PDF.js | PSPDFKit, then that canvas can be passed to a DynamicTexture: Dynamic Textures | Babylon.js Documentation and rendered using Babylon. :smiley:

4 Likes

Love this solution @carolhmj!!

If you need a DOM-based solution @mixofo , you could try looking into <iframe> or <embed>. However, you may run into compatibility issues with different browsers. This Stack Overflow thread goes into some detail: HTML embedded PDF iframe - Stack Overflow