Export to single HTML with embedded images using Jasper Report

前端 未结 5 898
天命终不由人
天命终不由人 2021-01-04 20:32

Can Jasper Report export to single HTML with embedded images?

I have output of jasper reports as single Excel file, PDF, RTF. But multiplay HTML files. It trouble fo

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-04 21:34

    A minor improvement to Dave Jarvis solution.

    Instead of hard-coding the mime type in

    images.put(id, "data:image/jpg;base64," + Base64.encodeBytes(data));
    

    You can try to discover the mime type like this:

    // Find out the mime type
    final ByteArrayInputStream bis = new ByteArrayInputStream( data );
    final String mimeType = URLConnection.guessContentTypeFromStream( bis );
    // Convert to an embedded "data" url.
    final String base64Data = "data:"+mimeType+";base64,"+Base64.encodeBytes( data );
    imagesMap.put( id, base64Data );
    

提交回复
热议问题