Home
Analytics
Set pageBreakInterval for export to pdf from the webviewer
richie.riviere
<p>Hi,</p>
<p> </p>
<p>Been a long day today.</p>
<p> </p>
<p>I've been trying to find a way to set a page break interval in my report design specific to exporting to PDF from the BIRT web report viewer.</p>
<p> </p>
<p>To explain this more ...</p>
<p> </p>
<p>In the BIRT designer I have set the following page break settings on my table to :</p>
<p style="margin-left:40px;">Before: Auto</p>
<p style="margin-left:40px;">After: Auto</p>
<p style="margin-left:40px;">Inside: Auto</p>
<p style="margin-left:40px;">Page Break Interval: 20</p>
<p> </p>
<p>When I display the report in my BIRT report viewer I want these settings to hold true and therefore to have a page break after 20 records.</p>
<p> </p>
<p>But from the BIRT report viewer when the user exports to PDF I want to set a pageBreakInterval of equal to a different number. In my case I have a report parameter passed into the report where the user can specify a number. If they want 10 records per page they can enter that in.</p>
<p> </p>
<p>I am struggling to find a way to do this.</p>
<p> </p>
<p>In the beforeFactory of the report I tried to do this...</p>
<p> </p>
<p style="margin-left:40px;">if(reportContext.getOutputFormat()=="pdf") {</p>
<p style="margin-left:80px;">reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("mytable").setProperty("pageBreakInterval",params["PageBreakInterval"].value); </p>
<p style="margin-left:40px;">}</p>
<p> </p>
<p>But this does not work.</p>
<p> </p>
<p>I am using BIRT reports engine 3.7.2.</p>
<p> </p>
<p>Thanks in advance</p>
<p> </p>
<p> </p>
<p> </p>
Find more posts tagged with
Comments
mwilliams
Unfortunately, these properties are set in the run task. Exporting the report just runs the render task to export the report to another format. Your other options would be to put two tables in your report and use the visibility property to hide the correct table for html vs pdf formats. The problem with this option is that I think there's an issue with white space still happening where the hidden table is. The other option would be to use a URL or code to provide a link to execute the report in PDF format.
richie.riviere
<p>thanks for your answer Michael. I understand what you have stated in your answer.</p>
<p> </p>
<p>Unfortunately I don't think that adding a table and hiding based on output format would help me because the start point for all my users when viewing reports is the BIRT Report Viewer. So when they want a PDF they start int he BIRT report viewer and just hit export. And as you mention the render task is too late to tell birt how to paginate records.</p>
<p> </p>
<p>I have a question for you. Is there any way that you can re-run the report with pdf as the specified output format in the BIRT report viewer without bringing up the parameter page? I know you mentioned that I could add a link in the report but since my users are used to having export options in the report viewer buttons panel I would prefer them to be able to do there rather than inside the report.</p>
<p> </p>
<p>If that is not possible the only other way I can think of achieving what I am after is to change the javascript in BirtExportReportDialog.js to call the birt reports servlet with my parameters and run the report again where __format=pdf or add a link inside my report. Is that correct?</p>
<p> </p>
<p>thanks again</p>
mwilliams
You might try the visibility option in the property editor with two tables (you can hide for specific outputs here). If you change the report layout to auto, the blank space does not happen.
richie.riviere
Hi Michael.<br><br>
Sorry, on reflection I did not explain my previous post properly. Yes based on your answer I tried setting the visibility property to hide a table if the format was pdf. I can confirm that works when you generate a PDF report by hitting the BIRT reports servlet via a direct url with an output type specified as pdf. But when you export the report in PDF format from the BIRT report viewer it does not work and hence this is where I'm stuck. Because all my reports are shown to the user from the birt report viewer. <br><br>
Does that make sense or am I still missing something?
mwilliams
It seems to work for me on export from the viewer to PDF. What issue are you having?
richie.riviere
<p>Hi Michael,</p>
<p> </p>
<p>I can't get it to work. To illustrate I'm going to attach a sample report that uses ClassicModels as it's data source.</p>
<p> </p>
<p>Inside this report there are two tables.</p>
<p> </p>
<p>mytableForWebViewer - It's visibility expression is reportContext.getOutputFormat()=="pdf"</p>
<p>mytableForPdf - It's visibility expression is reportContext.getOutputFormat()!="pdf"</p>
<p> </p>
<p>mytableForWebViewer has no page breaks and mytableForPdf has page breaks after every 20 records.</p>
<p> </p>
<p>When I use eclipse and select "View Report as PDF"(See screenshot), mytableForPdf appears. This is what I expected.</p>
<p> </p>
<p>When I use eclipse and select "View Report in Web Viewer"(See screenshot), mytableForWebViewer appears. This is what I expected.</p>
<p> </p>
<p>BUT after the report shows in the web viewer if I then select "Export Report" with the export format of "PDF"(See screenshot), mytableForWebViewer appears in the exported PDF. This is NOT what I expected. Are you saying that this is not what happens for you?</p>
<p> </p>
<p>Thanks again</p>
<p> </p>
mwilliams
For the visibility of an element (if using the option in the property editor), you can specify specific outputs to hide for. Select a table, go to the visibility section of the property editor for that table, check the "Hide Element" check box, then, choose the "For Specific Outputs" radio button. After you do this, a list of outputs will appear below that you can choose to hide that table for. Let me know if you'd like me to modify your example to show this.
richie.riviere
<p>Thanks for your help Michael! I have sorted it out using the options you have spoken about..</p>
mwilliams
Great to hear!
richie.riviere
<p>Michael just one extra question on this if you don't mind. If I have two tables in a report using the same resultset, one is hidden for html output and the other one is hidden for pdf output, how does the resultset get executed?</p>
<p> </p>
<p>1. Does it execute the resultset once for each output? for example when I open in html it executes and then when I export to pdf it executes again?</p>
<p>2, Does it execute all the resultsets when opened in html, then when I export does it just hide and unhide elements visually?</p>
<p> </p>
<p>I guess this is a question fundamental to my understanding about BIRT.</p>
<p> </p>
<p>thanks</p>
mwilliams
The default behavior would be to only execute once. There is a setting for this in the property editor for the data set. Select your data set that both items are bound to and go to the advanced section of the property editor. Look for the "needs cache for data-engine" property. It should be true by default. If so, the data set shouldn't run for each element. When you export, the report document is used to create the exported report, so the data set is not executed again.<br><br>Hope this answers your questions.