Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Page number and total page
Page number and total page [message #774451] Tue, 03 January 2012 18:52 Go to next message
Jason Nguyen is currently offline Jason Nguyen
Messages: 7
Registered: January 2012
Junior Member
I have a requirement to add page number and total page to the report directly, which is a form. I copy and paste those 2 fields from master page over the report. The total page shows the correct value; however, the current page always shows a value of one. Is there anything I need to setup to get it working correctly?
Thanks,
Re: Page number and total page [message #774831 is a reply to message #774451] Wed, 04 January 2012 13:00 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Can you use a text element and set its type to html and put in the
following expression:

<viewtime-value-of>
pageNumber
</viewtime-value-of>

Jason

On 1/3/2012 6:52 PM, Jason Nguyen wrote:
> I have a requirement to add page number and total page to the report
> directly, which is a form. I copy and paste those 2 fields from master
> page over the report. The total page shows the correct value; however,
> the current page always shows a value of one. Is there anything I need
> to setup to get it working correctly?
> Thanks,


Jason Weathersby

BIRT Exchange
Re: Page number and total page [message #774864 is a reply to message #774831] Wed, 04 January 2012 15:01 Go to previous messageGo to next message
Jason Nguyen is currently offline Jason Nguyen
Messages: 7
Registered: January 2012
Junior Member
I did exactly what you said and I see the "pageNumber", not the numerical page number value.
Re: Page number and total page [message #774882 is a reply to message #774864] Wed, 04 January 2012 15:57 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Did you set the type to html? What version of BIRT are you using?

On 1/4/2012 3:01 PM, Jason Nguyen wrote:
> I did exactly what you said and I see the "pageNumber", not the
> numerical page number value.


Jason Weathersby

BIRT Exchange
Re: Page number and total page [message #774888 is a reply to message #774882] Wed, 04 January 2012 16:10 Go to previous messageGo to next message
Jason Nguyen is currently offline Jason Nguyen
Messages: 7
Registered: January 2012
Junior Member
Version 2.3.2. Yes, I set it to HTML.
Re: Page number and total page [message #774894 is a reply to message #774888] Wed, 04 January 2012 16:30 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Sorry,

View-Time value of was not available until BIRT 2.6. I am not certain
if <VALUE-OF>pageNumber</VALUE-OF> will work but you could give it a try.

Jason


On 1/4/2012 4:10 PM, Jason Nguyen wrote:
> Version 2.3.2. Yes, I set it to HTML.


Jason Weathersby

BIRT Exchange
Re: Page number and total page [message #774902 is a reply to message #774894] Wed, 04 January 2012 17:00 Go to previous messageGo to next message
Jason Nguyen is currently offline Jason Nguyen
Messages: 7
Registered: January 2012
Junior Member
After I changed to <VALUE-OF>pageNumber</VALUE-OF>
I get 1's in all the header pages of the form. Is pageNumber a reserved name in Birt? Is it tied to a particular field at all? How does that variable get incremented in Birt? Thanks.
Re: Page number and total page [message #774935 is a reply to message #774902] Wed, 04 January 2012 19:11 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

pageNumber is a reserved name but works on the layout in later versions
of BIRT. It has to be viewed using the frameset mapping (separate run
and render task). This is where the variable gets incremented.

Jason

On 1/4/2012 5:00 PM, Jason Nguyen wrote:
> After I changed to <VALUE-OF>pageNumber</VALUE-OF>
> I get 1's in all the header pages of the form. Is pageNumber a reserved
> name in Birt? Is it tied to a particular field at all? How does that
> variable get incremented in Birt? Thanks.


Jason Weathersby

BIRT Exchange
Re: Page number and total page [message #775227 is a reply to message #774935] Thu, 05 January 2012 10:42 Go to previous messageGo to next message
Jason Nguyen is currently offline Jason Nguyen
Messages: 7
Registered: January 2012
Junior Member
Are you saying version 2.3.2 has a bug that pagenumber is not working? Is there a way that I can get around this bug?
Re: Page number and total page [message #775283 is a reply to message #775227] Thu, 05 January 2012 13:03 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

How are you viewing the report? With the web viewer using the frameset
mapping?

Jason

On 1/5/2012 10:42 AM, Jason Nguyen wrote:
> Are you saying version 2.3.2 has a bug that pagenumber is not working?
> Is there a way that I can get around this bug?


Jason Weathersby

BIRT Exchange
Re: Page number and total page [message #775316 is a reply to message #775283] Thu, 05 January 2012 13:59 Go to previous messageGo to next message
Jason Nguyen is currently offline Jason Nguyen
Messages: 7
Registered: January 2012
Junior Member
I am viewing the report in pdf. Do you have a sample code somewhere? What version of Birt the pageNumber is working properly?
Re: Page number and total page [message #775322 is a reply to message #775316] Thu, 05 January 2012 14:07 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

I am attaching a 3.7 report. Look at the green field. BTW in the
designer it does not work correctly when previewing directly to pdf. I
first preview in the web viewer and then export to pdf and it works.
This is because view in pdf uses a runandrender task as opposed to run
task then a separate render task. Page scripts have to have separate tasks.

Jason

On 1/5/2012 1:59 PM, Jason Nguyen wrote:
> I am viewing the report in pdf. Do you have a sample code somewhere?
> What version of Birt the pageNumber is working properly?


Jason Weathersby

BIRT Exchange
icon3.gif  Re: Page number and total page [message #1067972 is a reply to message #774451] Thu, 11 July 2013 09:47 Go to previous message
Henning von Bargen is currently offline Henning von Bargen
Messages: 14
Registered: May 2011
Junior Member
I try to avoid everything page-numbering related with BIRT itself, as it is all buggy (e.g. it doesn't work at all with RunAndRenderTask, and separate RunTask and RenderTask breaks pagination...) (see e.g. a Bugzilla entry by yaytay).

Intead, we are using a PostProcessor:

The BIRT Report tells the PostProcessor where, in which format, and under which conditions the page numbering should be added.

This is a bit ugly when designing the report (as the position has to be fixed, e.g. it is impossible to do this in a flow text), but it is working fine for all the reports we developed until now.

Features:
BIRT can feed the PostProcessor with several of "PageNumberingInstructions".
Each one has the following information:
- Font (Name, Bold?, Italic?, ptSize)
- Format e.g. "Page {0} of {1}"
- Rect (absolute position on the page in PDF units)
- Alignment Left/Right/Center
- Condition as a Javascript expression, e.g. "page==1" or "page>1"
- ResetAtLevel (optional)
As a special feature, the PostProcessor uses the PDF Outline (Table-of-Contents in BIRT-speech) to find out about grouping information. Inside the Format and the Condition, the PostProcessor can use this information.
With "ResetAtLevel", you can reset the page numbering to 1 whenever a TOC entry of the given level (or lower) changes.
With "{2}" in the Format, you can display the Outline/TOC Root (level 0) text, with "{3}", you can display the current text for TOC level 1, "{4}" is the current TOC level 2 text and so on.
This allows a "grouped page numbering".

E.g. if the TOC is like this:
My Report        physical page
  Preface        1 .. 3 
  Chapter 1      4 .. 8
    Section 1    4 .. 6
    Section 2    7 .. 8
  Chapter 2      9 .. 10
    Section 1    9
    Section 2    9 .. 10

Say, you want the page-numbering only for the actual content, not for the preface, and it should show only the page inside the current chapter in the page header.
You also want to display the current Chapter and Section centered in the page footer.

Then you could use this:

// First instruction, for the Page-Numbering
.Font = ...;
.Format = "Page {0} of {1}";
.Rect = ...;
.ResetAtLevel = 1; // for each chapter
.Condition = "context[1].substring(0,6) == 'Chapter'";
// Inside the preface, this is false, while true inside the chapters

// Next instruction, for the current Chapter and Section text
.Font = ...;
.Format = "{3} - {4}";
// {2} is TOC context level 0 (My Report), {3} is TOC context level 1 (Chapter ...)
// and so on
.Rect = ...;
.Condition = "context[1].substring(0,6) == 'Chapter'";
// Inside the preface, this is false, while true inside the chapters

If anyone is interested, please contact me via www.t-p.com (ask for Henning)

Of course it would be better if BIRT supported this out of the box...

[Updated on: Thu, 11 July 2013 09:48]

Report message to a moderator

Previous Topic:UPDATE database record after/just before report closes
Next Topic:How to restart page numbering within a group in BIRT 3.7.1
Goto Forum:
  


Current Time: Fri Apr 18 11:51:16 EDT 2014

Powered by FUDForum. Page generated in 0.03954 seconds