Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Page number and total page
Page number and total page [message #774451] Tue, 03 January 2012 23:52 Go to next message
Jason Nguyen is currently offline Jason NguyenFriend
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 18:00 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
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,
Re: Page number and total page [message #774864 is a reply to message #774831] Wed, 04 January 2012 20:01 Go to previous messageGo to next message
Jason Nguyen is currently offline Jason NguyenFriend
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 20:57 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
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.
Re: Page number and total page [message #774888 is a reply to message #774882] Wed, 04 January 2012 21:10 Go to previous messageGo to next message
Jason Nguyen is currently offline Jason NguyenFriend
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 21:30 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
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.
Re: Page number and total page [message #774902 is a reply to message #774894] Wed, 04 January 2012 22:00 Go to previous messageGo to next message
Jason Nguyen is currently offline Jason NguyenFriend
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] Thu, 05 January 2012 00:11 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
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.
Re: Page number and total page [message #775227 is a reply to message #774935] Thu, 05 January 2012 15:42 Go to previous messageGo to next message
Jason Nguyen is currently offline Jason NguyenFriend
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 18:03 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
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?
Re: Page number and total page [message #775316 is a reply to message #775283] Thu, 05 January 2012 18:59 Go to previous messageGo to next message
Jason Nguyen is currently offline Jason NguyenFriend
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 19:07 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
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?
icon3.gif  Re: Page number and total page [message #1067972 is a reply to message #774451] Thu, 11 July 2013 13:47 Go to previous messageGo to next message
Henning von Bargen is currently offline Henning von BargenFriend
Messages: 23
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 13:48]

Report message to a moderator

Re: Trick for total page count in BIRT PDF !!!!!!!! [message #1385345 is a reply to message #774451] Thu, 05 June 2014 18:14 Go to previous message
Sonal Gupta is currently offline Sonal GuptaFriend
Messages: 1
Registered: June 2014
Junior Member
Basically total page doesn't work with BIRT API.
Trick to get the pagecount
1:First generate the PDF (temporary pdf)
2: Calculate the total pages and send it as report parameter and use it in final pdf

sample code

public StreamedContent getFile() {
DefaultStreamedContent file = null;
InputStream stream = null;
try {
stream = generateSoapNotePdf(null);
PdfReader reader = new PdfReader(stream);
int pageCount = reader.getNumberOfPages();
reader.close();
stream = generateSoapNotePdf(""+pageCount);


file = new DefaultStreamedContent(stream, "application/pdf",
"encounterSOAP.pdf");

return file;

} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}

}

public InputStream generateSoapNotePdf(String pageCount) {

List<ReportParameter> parameters = new ArrayList<ReportParameter>();
parameters.add(new ReportParameter("encounterId", this.encounter
.getId().toString()));
parameters.add(new ReportParameter("pageCount", pageCount));
ByteArrayOutputStream bos = new ByteArrayOutputStream();

try {
reportingService.generateReport("encounterSOAP.rptdesign",
Report.RENDER_PDF, parameters, bos);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new RuntimeException(e);
}

InputStream stream = new ByteArrayInputStream(bos.toByteArray());

return stream;

}
Previous Topic:BIRT REPORT
Next Topic:Keeping sort order after joining two data sets.
Goto Forum:
  


Current Time: Thu Apr 18 23:48:22 GMT 2024

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

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

Back to the top