Menu

JWebBrowser - Is it possible to provide additional files like images that can then be used by the html supplied

Help
2022-02-28
2022-03-02
  • Matthew Boehm

    Matthew Boehm - 2022-02-28

    Hi All,

    Im using JWebBrower.setHTMLContent() and its working fine for rendering HTML and external links.
    Is it posisble tho to someone pass files using code so that they can be used in links/images..

    for example, instead of needing an external link for a image on the page, is it possible to just use logo.jpg... and somehow pass that image into the browser in the same way setHTMLContent is used?

    Thanks

     
    • Lóránd Kútvölgyi

      You can use navigate method to render images on your filesystem. JWebBrower.navigate("file:///logo.jpg");

       
      • Matthew Boehm

        Matthew Boehm - 2022-03-02

        Hi, Yeah I reliase that, however I want to serve up the html content to the user without needing to store tempory data on the filesystem

         
  • benchpresser

    benchpresser - 2022-03-02

    yes you can convert the image data to base64 and set as html content without need to any extra file or storage or file path etc.

    img src="data:image/png;base64, iVBOR..rkJggg=="

     

    Last edit: benchpresser 2022-03-02
    • Matthew Boehm

      Matthew Boehm - 2022-03-02

      awesome, this sounds perfect, thanks!

       

Log in to post a comment.

MongoDB Logo MongoDB