AlexBb Posted February 22 Share Posted February 22 Hello, we are facing regression in jasper report version 6.20.0. For some unknown reason scriptlet is executed twice for element that place in a band that does not fit remaining page size. We did not face with this issue in 6.4.3. Could you please help to resolve this issue. Reproduction path: public class JasperRepro { public static void main(String[] args) throws JRException, FileNotFoundException { JasperDesign myDesign = new JasperDesign(); myDesign.setName("my name"); myDesign.setScriptletClass("CaptionScriptlet"); myDesign.setPageHeight(500); JRDesignStyle jasperStyle = new JRDesignStyle(); jasperStyle.setName("my style"); jasperStyle.setFontSize(72F); myDesign.addStyle(jasperStyle); JRDesignSection details = (JRDesignSection) myDesign.getDetailSection(); JRDesignBand firstPageBand = new JRDesignBand(); firstPageBand.setHeight(300); details.addBand(firstPageBand); JRDesignBand secondBand = new JRDesignBand(); //Scriptlet is executed twice when band has SplitTypeEnum.PREVENT split type secondBand.setSplitType(SplitTypeEnum.PREVENT); //We expect that elements will be stretched with setTextAdjust(TextAdjustEnum.STRETCH_HEIGHT); //Band has 2 elements with TextAdjustEnum.STRETCH_HEIGHT, one of element of them has configured scriptlet //Defining minimum possible height secondBand.setHeight(2); JRDesignTextField element = new JRDesignTextField(); element.setExpression(new JRDesignExpression("\"" + JRStringUtil.escapeJavaStringLiteral("test") + "\"")); //minimal possible height, elements will be stretched with setTextAdjust(TextAdjustEnum.STRETCH_HEIGHT); element.setHeight(1); element.setY(0); element.setWidth(400); element.setStyle(jasperStyle); element.setPositionType(PositionTypeEnum.FLOAT); element.setTextAdjust(TextAdjustEnum.STRETCH_HEIGHT); secondBand.addElement(element); //Scriptlet which executed twice String myScriptlet = "((" + CaptionScriptlet.class.getName() + ")$P{REPORT_SCRIPTLET})"; JRDesignTextField elementWithScriptlet = new JRDesignTextField(); elementWithScriptlet.setExpression(new JRDesignExpression(String.format("%s.addCaption(\"%s\")", myScriptlet, "times scriptlet is executed: "))); //minimal possible height, elements will be stretched with setTextAdjust(TextAdjustEnum.STRETCH_HEIGHT); elementWithScriptlet.setHeight(1); elementWithScriptlet.setWidth(400); elementWithScriptlet.setY(1); elementWithScriptlet.setPositionType(PositionTypeEnum.FLOAT); elementWithScriptlet.setStyle(jasperStyle); elementWithScriptlet.setTextAdjust(TextAdjustEnum.STRETCH_HEIGHT); secondBand.addElement(elementWithScriptlet); details.addBand(secondBand); //EXPORT to pdf JasperReport jasperReport = JasperCompileManager.compileReport(myDesign); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap<>(), new JREmptyDataSource()); JRPdfExporter exporter = new JRPdfExporter(); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(new FileOutputStream("c:\\dev\\my.pdf"))); SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration(); configuration.setPermissions(PdfWriter.AllowCopy | PdfWriter.AllowPrinting); exporter.setConfiguration(configuration); exporter.exportReport(); } } public class CaptionScriptlet extends JRDefaultScriptlet { private int number = 0; public String addCaption(String caption) { return caption + " " + ++number; } } Link to comment Share on other sites More sharing options...
Tirupathi Mangalarapu Posted March 1 Share Posted March 1 Hello Alex, Thanks for sharing the details. First of all, is this a community version or a Commercial version? If you are using the community version, Can you please also do this: Please record a video of the issue using some free tools like Screencast and also attach the sample reports along with sample data so it's easy for us to review it here and then pass it to our engineering team and show them the behavior that you described. If you are using a commercial version of our product: Please open a support ticket and report this issue through a support ticket so that can be tracked and be addressed Thank you 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