jasperreportsUsersSince200 Posted October 17, 2023 Share Posted October 17, 2023 Hello out there,we were just happily upgrading from jasperreports 6.12.2 to 6.20.6. Everything went smoothly - only one big thing:In order to customize their document layout, our users can paste base64-encoded images in their JRXML-file. They do this by defining a variable (string) and pasting the base64-encoded image value in the variable expression. Here is an example with a simple 10x10px image (png).<variable name="customImage" class="java.lang.String"><variableExpression><!CDATA["iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAABhJREFUGJVj/DqX4T8DEYCJGEWjCqmnEAAn6QKldRfUigAAAABJRU5ErkJggg=="]]></variableExpression></variable>This variable is then used within an image expression javax.imageio.ImageIO.read(new java.io.ByteArrayInputStream(java.util.Base64.getDecoder().decode($V{customImage})))Unfortunately, we are experiencing serious compile issues with multiple JRXML-files - whenever it comes to more complex images (resulting in huge string values in the variable, background images easily take up to 160k characters). We even had files with compile issues, where the customImage variable had a quite big value - but the variable was never used in an image.None of the JRXML-files, that are now having compile errors, have been touched ever since - with version 6.12 (or below) we never had issues handling images this way.We are also having problems with images, where the source is provided to the report via a byte array - as soon as the image source is for example 8000 x 2000pxWe are happy to provide more details - is there any known incompatibility with java/tomcat or any other hint for us?Thank you so much for helping us out!Regards, Gerd Link to comment Share on other sites More sharing options...
Mehak Rajkumar Posted October 18, 2023 Share Posted October 18, 2023 Thank you for posting to the Jaspersoft Community. Our team of experts has read your question and we are working to get you an answer as quickly as we can. If you have a Jaspersoft Professional Subscription plan, please visit https://support.tibco.com/s/ for direct access to our technical support teams offering guaranteed response times. Link to comment Share on other sites More sharing options...
Teodor Danciu Posted October 23, 2023 Share Posted October 23, 2023 Hi,If you have a JRXML with a big Base64 image in it that used to work in 6.12.2 and no longer works in 6.20.6, please share it with us.Thank you,Teodor Link to comment Share on other sites More sharing options...
jasperreportsUsersSince200 Posted October 24, 2023 Author Share Posted October 24, 2023 Hello Teodor,thank you so much for looking into our issue! Of course!We have prepared an archive withhttps://nextcloud.rise-world.com/s/cAdmYqL8wtkceTk* file a: variable "streamBackground" contains a large string, but is never used in any image (as soon as we remove the variable, the PDF-creation is successful)* file b: two images are pasted in header and footer (via variable "KOPF" and "img_fuss"; as soon as we replace the variable values with a much shorter string, the PDF-creation is successful)* file c: large image handling (when provided by byte array from db in parameter logo) with failing image (8268 x 3543px logo), this report works perfectly fine as soon as we compress the logo before storing it in the databaseJust to make sure: in Jaspersoft Studio those files all do compile successfully - the problems start by the time we trigger the PDF-creation on our jasper reports server (where we also fill the missing parameters and field-values).The exceptions we get, don't make sense at all (like ClassCastException), we tried debugging and found, that in those cases the variable and parameter value handling is messed up.This is our environment* java 17* tomcat 9* we use rhino as js framework in jasperHope that helps!Regards, Gerd Link to comment Share on other sites More sharing options...
Teodor Danciu Posted October 31, 2023 Share Posted October 31, 2023 Hi,There seems to be no variable called "streamBackground" in the "a" JRXML. Maybe I'm missing something...When the "b" and "c" reports fails on your side, what is the error you have in logs for each of them?Can you provide the stack traces of these errors?Thank you,Teodor Link to comment Share on other sites More sharing options...
Mehak Rajkumar Posted November 7, 2023 Share Posted November 7, 2023 Hi JS User, We are eagerly anticipating your response to the comment mentioned above. Please provide the requested information so that we can assist you in addressing your question effectively. Link to comment Share on other sites More sharing options...
jasperreportsUsersSince200 Posted November 8, 2023 Author Share Posted November 8, 2023 Hi Team,thank you for the reminder, and sorry for the delay!We had already thought that the files alone would be of little help. Unfortunately, the exceptions we get, do not make any sense - as they do not show the root cause. In File B for example, during PDF-generation we get a class cast exception, a parameter that is expecting a Boolean value, suddenly gets a String value (that is supposed for a different parameter). It seems, the parameter/variable/field handling gets confused, in case a file contains a large String (like a long Base64 string) - or the image representation as a byte array (2000px and more).We are working on providing a demo project for you, unfortunately we need a little more time for that. Currently, we help ourselves by compressing all images as extensive as possible, so we don't run into this issue for troubled files.RegardsGerd Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now