Community
Participate
Working Groups
See attached report. Run in viewer and check page 2 of shipped category. It works in HTML. Export to PDF and the incorrect value is displayed.
Created attachment 171428 [details] example report look at the text element with this expression: <viewtime-value-of> vars["GROUP_PAGE"] </viewtime-value-of>
PLease evaluate the risk of fixing this in 2.6 RC4, if too large a change, please consider 2.6.1.
Page break scripts are invoked on the run time, it means once the run time pagination is created, the page variable value won't be changed anymore. In your design, the report uses the auto layout. In this case, the PDF pagination may not equal to the HTML pagination due to the limitation of the master page size. You can change it to fix layout and retry.
You can also change the page style to "Fit to Whole Page" in the PDF export dialog, so the PDF uses the same pagination with HTML. As it is not a bug, I set it to INVALID.
I can't change to fixed layout as the viewer throws an exception on the pageend script. I am not certain why. I do not know what you mean by: Page break scripts are invoked on the run time, it means once the run time pagination is created, the page variable value won't be changed anymore.
For auto-layout, the PDF pagination is not equal to the HTML pagination. The HTML pagination is done in the run time with the page script executing. To render the HTML page to PDF, the user can choose if one HTML page should be outputted to one or multiple pages if the page content is larger than the master page size. If the user prefers multiple pages which is the "auto" page style in PDF export dialog, the HTML page is re-paginated based on the page size. In this case, the onPageScript won't be executed. You may see that the page variable's value is not correct for the new created pages. If the user prefers one page which is the "Fit to Whole page" mode, each HTML page is outputted to one PDF page. In this mode, as the PDF pagination is consistent with the HTML pagination, the result is correct. Anyway, to resolve this issue, you can either choose the fix-layout or use the "fit to whole page" output mode as a workaround.
Need to fix the exception in the pageend script when using fix-layout? Jason, can you copy the exception message into comments?
re-open this issue as there is an class cast exception in the onPageEnd: org.eclipse.birt.report.engine.ir.SimpleMasterPageDesign cannot be cast to org.eclipse.birt.report.engine.ir.ReportItemDesign (/report/page-setup/simple-master-page[@id="2"]/method[@name="onPageEnd"]#1) at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1654) at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:175) at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:243) at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66) at org.mozilla.javascript.gen.c20._c0(/report/page-setup/simple-master-page[@id="2"]/method[@name="onPageEnd"]:1) at org.mozilla.javascript.gen.c20.call(/report/page-setup/simple-master-page[@id="2"]/method[@name="onPageEnd"]) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3003) at org.mozilla.javascript.gen.c20.call(/report/page-setup/simple-master-page[@id="2"]/method[@name="onPageEnd"]) at org.mozilla.javascript.gen.c20.exec(/report/page-setup/simple-master-page[@id="2"]/method[@name="onPageEnd"]) at org.eclipse.birt.report.engine.javascript.JavascriptEngine.evaluate(JavascriptEngine.java:282) ... 34 more Caused by: java.lang.ClassCastException: org.eclipse.birt.report.engine.ir.SimpleMasterPageDesign cannot be cast to org.eclipse.birt.report.engine.ir.ReportItemDesign at org.eclipse.birt.report.engine.script.internal.instance.PageInstance.getInstancesByElementName(PageInstance.java:79) at sun.reflect.GeneratedMethodAccessor34.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:160) ... 43 more
Created attachment 171433 [details] example It is complaining when using either: //var groups = this.getInstancesByElementName("GROUP_STATUS"); //var groups = this.getInstancesByElementId(73); So I modified the report to use another method and it let me set fixed. Please run this in the viewer and then export to pdf to see the issue.
Fix the class cast exception. 1. Check if IContent.getGenerateBy() returns ReportElementDesign. 2. Cast to ReportElementDesign instead of ReportItemDesign.
1. When export to PDF and fit to whole page, the page variable works correctly. 2. No exception on the pageend script. Verified in build (2.6.0.v20100609-1747).