Open PDF in the canvas

Hi,

I would like to know if it is possible to open a PDF onto a canvas like an iframe view. Are there any examples?

Well, question is not really Babylon related, but this might help you.

1 Like

For this purpose I would recommend to use pdf.js from Mozilla. You may use iframe or put ctx to Dynamic Texture inside 3D scene, it is up to you.
https://mozilla.github.io/pdf.js/

1 Like

Thanks! Can you recommend any example to follow ? Because I am not sure how to integrate it in Babylon.

Take the simplest one as at https://jsfiddle.net/pdfjs/9engc9mw/
Get the content of PDF to canvas, then do with this canvas what you need to.
To use this canvas for Dynamic Texture see Dynamic Textures | Babylon.js Documentation

3 Likes

Would be nice to see your implementation :slight_smile:

Hey I used as simple as an iframe with higher z-index. It works as expected :slight_smile: I can add http links, images and also pdfs :slight_smile:


    <iframe
  src="myPDF.pdf"
  style="
    position: fixed;
    top: 0px;
    bottom: 0px;
    right: 0px;
    width: 100%;
    border: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    z-index: 999999;
    height: 100%;
  ">
</iframe>
1 Like