Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Page number always 1 in the masterpage of the report generated by program
Page number always 1 in the masterpage of the report generated by program [message #559075] Wed, 15 September 2010 14:15 Go to next message
diyfan  is currently offline diyfan Friend
Messages: 3
Registered: May 2010
Junior Member
Hello,

I found a problem of autotext of PageNumber in MasterPage

The page number is always 1 if the report is designed and generated by Java program.

To reproduce the problem, you create an empty rptdesign file with A4 size and put an autotext of page number in the header of MasterPage, then use the program below to generate the report:

public static void main(String[] args) {
try {
EngineConfig config = new EngineConfig();
config.setBIRTHome("E:\\eclipsebirtsdk\\birt-runtime-2_6_0\\ReportEngine ");
Platform.startup(config);

IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_E NGINE_FACTORY);
IReportEngine bre = factory.createReportEngine(config);

String eoRptDesignFilePath = "C:\\projets\\java\\doccompta\\PisteAuditReport\\" +
"test_report.rptdesign";
IReportRunnable eoRptDesign = bre.openReportDesign(eoRptDesignFilePath);
ElementFactory designFactory = eoRptDesign.getDesignHandle().getElementFactory( );
ReportDesignHandle rdh = (ReportDesignHandle)eoRptDesign.getDesignHandle();

for(int i = 0; i < 1000; i++) {
LabelHandle dataNameLabel = designFactory.newLabel(null);
dataNameLabel.setText(String.valueOf(i));

rdh.getBody().add(dataNameLabel);
}
IRunTask runTask = bre.createRunTask(eoRptDesign);
String rptDocFilePath = "c:\\temp\\temp.rptdocument"; //fichier temporaire de birt
runTask.run(rptDocFilePath);

IReportDocument rptdoc = bre.openReportDocument(rptDocFilePath);
IRenderTask renderTask = bre.createRenderTask(rptdoc);

IRenderOption option = new PDFRenderOption();
option.setOutputFormat(RenderOption.OUTPUT_FORMAT_PDF);
option.setOutputFileName("c:\\temp\\a.pdf");

renderTask.setRenderOption(option);

renderTask.render();
renderTask.close();

rptdoc.close();

new File(rptDocFilePath).delete();

bre.destroy();

System.out.println("ok");
Desktop.getDesktop().open(new File("c:\\temp\\a.pdf"));

System.exit(0);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
Re: Page number always 1 in the masterpage of the report generated by program [message #559108 is a reply to message #559075] Wed, 15 September 2010 15:31 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

This does look like a bug. Can you report it? To work around it can
you change your for loop to do the following:

for(int i = 0; i < 1000; i++) {
LabelHandle dataNameLabel = designFactory.newLabel(null);
dataNameLabel.setText(String.valueOf(i));

if( (i % 20) == 0 && i > 0 ){
dataNameLabel.setProperty("pageBreakAfter", "Always");
}


rdh.getBody().add(dataNameLabel);
}

On 9/15/2010 10:15 AM, diyfan wrote:
> public static void main(String[] args) {
> try {
> EngineConfig config = new EngineConfig();
>
> config.setBIRTHome("E:\\eclipsebirtsdk\\birt-runtime-2_6_0\\ReportEngine
> ");
> Platform.startup(config);
>
> IReportEngineFactory factory = (IReportEngineFactory) Platform
>
> .createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_E
> NGINE_FACTORY);
> IReportEngine bre = factory.createReportEngine(config);
> String eoRptDesignFilePath =
> "C:\\projets\\java\\doccompta\\PisteAuditReport\\" +
>
> "test_report.rptdesign"; IReportRunnable
> eoRptDesign = bre.openReportDesign(eoRptDesignFilePath);
> ElementFactory designFactory =
> eoRptDesign.getDesignHandle().getElementFactory( );
> ReportDesignHandle rdh =
> (ReportDesignHandle)eoRptDesign.getDesignHandle();
> for(int i = 0; i < 1000; i++) {
> LabelHandle dataNameLabel = designFactory.newLabel(null);
> dataNameLabel.setText(String.valueOf(i));
> rdh.getBody().add(dataNameLabel);
> }
> IRunTask runTask = bre.createRunTask(eoRptDesign);
> String rptDocFilePath = "c:\\temp\\temp.rptdocument";
> //fichier temporaire de birt
> runTask.run(rptDocFilePath);
> IReportDocument rptdoc =
> bre.openReportDocument(rptDocFilePath);
> IRenderTask renderTask = bre.createRenderTask(rptdoc);
> IRenderOption option = new PDFRenderOption();
> option.setOutputFormat(RenderOption.OUTPUT_FORMAT_PDF);
> option.setOutputFileName("c:\\temp\\a.pdf");
> renderTask.setRenderOption(option);
> renderTask.render();
> renderTask.close();
> rptdoc.close();
> new File(rptDocFilePath).delete();
> bre.destroy();
> System.out.println("ok");
> Desktop.getDesktop().open(new File("c:\\temp\\a.pdf"));
> System.exit(0);
> } catch (Exception e) {
> e.printStackTrace();
> System.exit(1);
> }
> }
Re: Page number always 1 in the masterpage of the report generated by program [message #559109 is a reply to message #559075] Wed, 15 September 2010 15:55 Go to previous messageGo to next message
diyfan  is currently offline diyfan Friend
Messages: 3
Registered: May 2010
Junior Member
Thank you for the quick answer.

I will report this problem to BIRT.

Another solution is to use IRunAndRenderTask but I think that it may cause other problems in the report.

best regards
Re: Page number always 1 in the masterpage of the report generated by program [message #559611 is a reply to message #559109] Fri, 17 September 2010 11:02 Go to previous messageGo to next message
Helmut Neubauer is currently offline Helmut NeubauerFriend
Messages: 54
Registered: July 2009
Member
Can you give us the link of your bug report?

We've this problem, too. It's a problem of BIRT 2.6, in 2.5 we didn't
have the problem.

If we use the BIRT web viewer to view our report all is ok. In HTML, our
report has 4 pages. If we than export the report to PDF the PDF takes
the page numbers of the HTML version. It has above to 50 pages but the
page numbers go from 1 to 4 like the HTML version.

Helmut


Am 15.09.2010 17:55, schrieb diyfan:
> Thank you for the quick answer.
>
> I will report this problem to BIRT.
>
> Another solution is to use IRunAndRenderTask but I think that it may
> cause other problems in the report.
>
> best regards
Re: Page number always 1 in the masterpage of the report generated by program [message #559612 is a reply to message #559611] Fri, 17 September 2010 11:04 Go to previous messageGo to next message
Helmut Neubauer is currently offline Helmut NeubauerFriend
Messages: 54
Registered: July 2009
Member
Sorry for posting two times. Is there any workaround, using scripts or
doing something else? We only use the predefined grid component n of m
in our master page.

Am 17.09.2010 13:02, schrieb Helmut Neubauer:
> Can you give us the link of your bug report?
>
> We've this problem, too. It's a problem of BIRT 2.6, in 2.5 we didn't
> have the problem.
>
> If we use the BIRT web viewer to view our report all is ok. In HTML, our
> report has 4 pages. If we than export the report to PDF the PDF takes
> the page numbers of the HTML version. It has above to 50 pages but the
> page numbers go from 1 to 4 like the HTML version.
>
> Helmut
>
>
> Am 15.09.2010 17:55, schrieb diyfan:
>> Thank you for the quick answer.
>>
>> I will report this problem to BIRT.
>>
>> Another solution is to use IRunAndRenderTask but I think that it may
>> cause other problems in the report.
>>
>> best regards
>
Re: Page number always 1 in the masterpage of the report generated by program [message #559653 is a reply to message #559612] Fri, 17 September 2010 13:51 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Helmut,

I think this is the issue:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=324860

Jason

On 9/17/2010 7:04 AM, Helmut Neubauer wrote:
> Sorry for posting two times. Is there any workaround, using scripts or
> doing something else? We only use the predefined grid component n of m
> in our master page.
>
> Am 17.09.2010 13:02, schrieb Helmut Neubauer:
>> Can you give us the link of your bug report?
>>
>> We've this problem, too. It's a problem of BIRT 2.6, in 2.5 we didn't
>> have the problem.
>>
>> If we use the BIRT web viewer to view our report all is ok. In HTML, our
>> report has 4 pages. If we than export the report to PDF the PDF takes
>> the page numbers of the HTML version. It has above to 50 pages but the
>> page numbers go from 1 to 4 like the HTML version.
>>
>> Helmut
>>
>>
>> Am 15.09.2010 17:55, schrieb diyfan:
>>> Thank you for the quick answer.
>>>
>>> I will report this problem to BIRT.
>>>
>>> Another solution is to use IRunAndRenderTask but I think that it may
>>> cause other problems in the report.
>>>
>>> best regards
>>
>
Re: Page number always 1 in the masterpage of the report generated by program [message #559869 is a reply to message #559653] Mon, 20 September 2010 07:41 Go to previous messageGo to next message
Helmut Neubauer is currently offline Helmut NeubauerFriend
Messages: 54
Registered: July 2009
Member
Jason,

thanks for your answer. Is it possible to do the page numbering in another way (using scripts or doing somethind else) as workaround until the bug is fixed?

Thanks,
Helmut
Re: Page number always 1 in the masterpage of the report generated by program [message #560197 is a reply to message #559869] Tue, 21 September 2010 14:09 Go to previous messageGo to next message
Helmut Neubauer is currently offline Helmut NeubauerFriend
Messages: 54
Registered: July 2009
Member
I tried using variables as workaround but I failed. I have the same effect. I used two variables, one report variable, one page variable and used the onPageEnd event in the master page to increment the report variable and assign the value to the page variable.

Any other idea?
Re: Page number always 1 in the masterpage of the report generated by program [message #560208 is a reply to message #559075] Tue, 21 September 2010 14:56 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Did you try setting pagebreakinterval?

Jason
Re: Page number always 1 in the masterpage of the report generated by program [message #626084 is a reply to message #560208] Wed, 22 September 2010 11:39 Go to previous messageGo to next message
Helmut Neubauer is currently offline Helmut NeubauerFriend
Messages: 54
Registered: July 2009
Member
I'm using charts and tables in my report. Considering the charts I've not the possiblity to set the pagebreakinterval.
Re: Page number always 1 in the masterpage of the report generated by program [message #626318 is a reply to message #559075] Wed, 22 September 2010 14:13 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Can you try setting pagebreakinterval to a high number and see if that works. If layout is fixed this should issue soft page breaks.

Jason
Previous Topic:Design ideas, using BIRT only as viewer ?
Next Topic:expandable/collapsible groups ?
Goto Forum:
  


Current Time: Thu Dec 18 15:30:54 GMT 2014

Powered by FUDForum. Page generated in 0.02570 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software