how to display dynamically generated html page with resources that are also


I’m trying to display a generated html page (generated by net.sf.jasperreports.engine.JasperExportManager.exportReportToHtmlFile()) using a CustomLayout in a Panel.
It look like this:

    CustomLayout html = new CustomLayout(new FileInputStream("htmlFile.html"));
    Panel htmlPanel = new Panel();

This works fine if there are no resources like images and fonts that are generated by the export manager, but when there are they are placed in “htmlFile.html_files” directory.
The problematic thing is this part of html:

    <td colspan="4">
    <img src="htmlFile.html_files/img_0_0_37" style="width: 13px" alt=""/></td>
    <td colspan="4" style="text-indent: 0px; text-align: right;">
    <span style="font-family: Arial-hr_HR; color: #000000; font-size: 10px; line-height: 1.1499023;">7:55</span></td>

    <link class="jrWebFont" rel="stylesheet" href="htmlFile.html_files/Arial-hr_HR">

When it gets displayed in the Layout the img src points to “http://localhost:8080/VAADIN/themes/mytheme/layouts/htmlFile.html_files/img_0_0_37”.
And the text is not in Arial, my guess is that the font link is also to the same location wich does not exist.
The real path is something like “/glassfish4/glassfish/domains/domain1/config/htmlFile.html_files/”.

The images are not a big problem as I could encode them in base64 and just parse them in the html file directly, but the font link are the problem.
First “htmlFile.html_files/Arial-hr_HR” is a css file:

    @charset "UTF-8";
    @font-face {
        font-family: 'Arial-hr_HR';
        src: local('☺'),
            url('Arial-hr_HR.ttf') format('truetype');
        font-weight: normal;
        font-style: normal;

My question is could these files somehow be moved to the same location as the html file or is there a better way to do this.
The fonts and images can’t be static because there are a lot of diferent reports with diferent images and fonts that are generated by the same web app.

Thanx in advance :slight_smile: