Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » BIRT 2.5.1: IReportDocument.getPageNumber(bookMark) returns wrong page number?
BIRT 2.5.1: IReportDocument.getPageNumber(bookMark) returns wrong page number? [message #513543] Wed, 10 February 2010 14:33 Go to next message
Steve van den Buys is currently offline Steve van den BuysFriend
Messages: 9
Registered: February 2010
Junior Member
Hello,

I'm using IReportDocument.getPageNumber(bookMark) (in BIRT 2.5.1) to get the page numbers for my bookmarks (which are then afterwards used to create a table of contents within a PDF document). You can see an example of this document HERE. As you can see from the example, the page numbers are wrong. They start of fine with items 1 and 2 but "3. Profielen" should have page number 5 instead of 4 (all items beyond this one have wrong numbers).

Is there something I am missing about the internal functioning of the getPageNumber-method? The way I set it up is that I marked all relevant parts of my report with bookmarks. Then I use RunTask to get an intermediate rptdocument and use that to get the bookmarks (and accompanying page numbers). These are then stored in a Map (key=bookmark string, value=page number) and added to the appContext of the RenderTask. Using a custom Java event handler (on dynamic text) I then replace the original value of the dynamic text (which is the same as the bookmark string) with the page number (using the original value of the dynamic text as the key lookup value in the Map).

Any help would be greatly appreciated as I'm a bit stuck since I would expect the getPageNumber-method to simply return me the correct page number.
Re: BIRT 2.5.1: IReportDocument.getPageNumber(bookMark) returns wrong page number? [message #513611 is a reply to message #513543] Wed, 10 February 2010 17:07 Go to previous messageGo to next message
Steve van den Buys is currently offline Steve van den BuysFriend
Messages: 9
Registered: February 2010
Junior Member
I experimented a bit further and tried another path but that doesn't work either. I added a PDF Table Of Contents and in between the RunTask and the RenderTask I used the IReportDocument.findTOC(null) method to get the root TOC. I then iterated over the TOC to get the bookmarks and then used that bookmark to get the page number (I somehow hoped that this would work as the items in the TOC do link to the right page). Unfortunately: the page numbers are wrong here as well (apparently the linking of the TOC items to the actual PDF content is not based on page number).
Re: BIRT 2.5.1: IReportDocument.getPageNumber(bookMark) returns wrong page number? [message #513662 is a reply to message #513611] Wed, 10 February 2010 18:36 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Steve,

The problem is that the bookmarks are based on the HTML pages not the
pdf pages. You will need to set page break intervals on your tables so
the HTML pages are equal to or smaller than the pdf pages to get this to
work like you want. BTW are you writting the TOC using iText?

Jason

Steve van den Buys wrote:
> I experimented a bit further and tried another path but that doesn't
> work either. I added a PDF Table Of Contents and in between the RunTask
> and the RenderTask I used the IReportDocument.findTOC(null) method to
> get the root TOC. I then iterated over the TOC to get the bookmarks and
> then used that bookmark to get the page number (I somehow hoped that
> this would work as the items in the TOC do link to the right page).
> Unfortunately: the page numbers are wrong here as well (apparently the
> linking of the TOC items to the actual PDF content is not based on page
> number).
Re: BIRT 2.5.1: IReportDocument.getPageNumber(bookMark) returns wrong page number? [message #513757 is a reply to message #513543] Thu, 11 February 2010 07:37 Go to previous messageGo to next message
Steve van den Buys is currently offline Steve van den BuysFriend
Messages: 9
Registered: February 2010
Junior Member
Jason,

then I'm afraid my solution isn't usable. Correct me if I'm wrong but as I understand it the page break interval works on the level of a number of rows (or list items) and not on the actual number of lines of text in a document. That is: page break works nicely in HTML-output because in HTML your pages can be of varying length but in PDF (or Word) an A4 page is always an A4 page.

This is a problem because the table rows and list items in our report have a varying amount of text within them (sometimes only 1 line, sometimes an entire page of text) so if I were to set page break interval to for example 2 then I would sometimes have almost empty pages (when there is only little text) and as soon as I have 2 rows that span more than one page, then my page numbering will be wrong from that point onwards.

Regarding the TOC: we use a scripted data source and a number of scripted data sets that access a POJO which in turn performs EJB calls to retrieve the required data. The retrieval of data is done in the constructor of the POJO. Once we have all the data we can generate a list of numbered (sub)chapters which then itself becomes a piece of data that is used by a ScriptedDataSet (that interacts with the POJO) to create the inline table of content. So: no, we don't use iText to generate the POC.
Re: BIRT 2.5.1: IReportDocument.getPageNumber(bookMark) returns wrong page number? [message #513769 is a reply to message #513543] Thu, 11 February 2010 08:28 Go to previous messageGo to next message
Steve van den Buys is currently offline Steve van den BuysFriend
Messages: 9
Registered: February 2010
Junior Member
Another idea: perhaps I could just use BIRT to generate the report without the page numbering in the table of contents and then afterwards use iText to open the generated document and go looking for my bookmarks (and accompanying page numbers) in the PDF itself? I suppose iText should be able to give me the correct page numbers (considering that at that moment we are already dealing with a rendered PDF document). If I then provide placeholders for the actual page numbers I could perhaps replace those with the correct page numbers.

Or even easier (well, relatively speaking): I could just remove the entire table of contents from the BIRT report and insert it afterwards using iText. But then I also have to remove the page numbers and insert those afterwards with iText as well (since I will have to insert a least one new page with the table of contents).
Re: BIRT 2.5.1: IReportDocument.getPageNumber(bookMark) returns wrong page number? [message #513803 is a reply to message #513543] Thu, 11 February 2010 11:21 Go to previous messageGo to next message
Steve van den Buys is currently offline Steve van den BuysFriend
Messages: 9
Registered: February 2010
Junior Member
Hmm, did some research in iText and it appears that my idea above isn't feasible either. Although you can use a PdfReader and something like the PdfStamper to manipulate an already existing PDF, this is rather limited (basically you can add stuff to a layer under or above the actual content but can't really manipulate existing content). Further: I'm still not able to get the relevant page numbers as the actual PDF bookmarks also refer to something else than a page number. And Bruno Lowagie (creator of iText for those who don't know) probably didn't write that section "Why you shouldn't use PDF as a format for editing" for nothing in his book "iText in Action"... Very Happy

Still, I'd expect more developers to sooner or later run into a client who asks (for more complex reports) for a table of contents with page numbers. Sure, you have the bookmarks and TOC functionality but once the report gets printed, a client no longer has that meta-data. And our particular client does exactly that: they have a web application where they can enter all their data which can then generate a report that is then printed and sent to their clients.

[Updated on: Thu, 11 February 2010 15:45]

Report message to a moderator

Re: BIRT 2.5.1: IReportDocument.getPageNumber(bookMark) returns wrong page number? [message #513900 is a reply to message #513803] Thu, 11 February 2010 11:08 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Steve,

I went through the same thing you did. I used BIRT to generate a PDF
with bookmarks and then used iText to write in a TOC at the beginning of
the PDF. This worked fine with the exception of not being able to get
the page numbers. The links worked, but I could not find a way in iText
to retrieve the page of a bookmark.

Are you using Fixed layout? I know we have a couple bugs in to address
this issue. You may want to try in the latest 2.5.2 or 2.6 build. We
also have a bug in to add a TOC to the beginning of a report.

Jason

Steve van den Buys wrote:
> Hmm, did some research in iText and it appears that my idea above isn't
> feasible either. Although you can use a PdfReader and something like the
> PdfStamper to manipulate an already existing PDF, this is rather limited
> (basically you can add stuff to a layer under or above the actual
> content but can't really manipulate existing content). Further: I'm
> still not able to get the relevant page numbers as the actual PDF
> bookmarks also refer to something else than a page number. And Bruno
> Lowagie (creator of iText for those who don't know) probably didn't
> write that section "Why you shouldn't use PDF as a format for editing"
> for nothing in his book "iText in Action"... :p
> Still, I'd expect more developers to sooner or later run into a client
> who asks (for more complex reports) for a table of contents with page
> numbers. Sure, you have the bookmarks and TOC functionality but once the
> report gets printed, a client no longer has that meta-data. And our
> particular client does exactly that: they have a web application where
> they can enter all their data which can then generate a report that is
> then printed and sent to their clients.
Re: BIRT 2.5.1: IReportDocument.getPageNumber(bookMark) returns wrong page number? [message #514067 is a reply to message #513543] Fri, 12 February 2010 10:57 Go to previous messageGo to next message
Steve van den Buys is currently offline Steve van den BuysFriend
Messages: 9
Registered: February 2010
Junior Member
Jason,

I was using Auto Layout but I just tried Fixed Layout and this works (at least for the example report)! So, with the setup as described in my first post (so no additional iText manipulation after BIRT report generation) this seems to work. But now I'll have to run a battery of tests to see if the page numbering is always correct for the report (given that the report design contains a lot of conditional logic and largely varying amounts of data from report to report).

So what exactly is the big difference between Auto Layout and Fixed Layout that (at first sight) makes this work?
Re: BIRT 2.5.1: IReportDocument.getPageNumber(bookMark) returns wrong page number? [message #514145 is a reply to message #514067] Fri, 12 February 2010 15:02 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Fixed layout attempts to honor page size and item positioning. Let us
know how your test go. It would be very cool if you could write
(blog/post) how you got the TOC on the first page. A lot of ppl ask for
this.

Jason

Steve van den Buys wrote:
> Jason,
>
> I was using Auto Layout but I just tried Fixed Layout and this works (at
> least for the example report)! So, with the setup as described in my
> first post (so no additional iText manipulation after BIRT report
> generation) this seems to work. But now I'll have to run a battery of
> tests to see if the page numbering is always correct for the report
> (given that the report design contains a lot of conditional logic and
> largely varying amounts of data from report to report).
>
> So what exactly is the big difference between Auto Layout and Fixed
> Layout that (at first sight) makes this work?
Re: BIRT 2.5.1: IReportDocument.getPageNumber(bookMark) returns wrong page number? [message #514162 is a reply to message #513543] Fri, 12 February 2010 16:32 Go to previous messageGo to next message
Steve van den Buys is currently offline Steve van den BuysFriend
Messages: 9
Registered: February 2010
Junior Member
Well, testing seems to go pretty well with just one problem I can't really get my head around: page numbering is off by one page as soon as the actual table of contents itself jumps from 20 to 21 lines (so: it's correct when there are 20 or less lines and wrong from the moment there are more than 20 lines). Oddly enough the actual page break interval of the List that renders these lines is set to 30. So, I'm not sure what's going on here but it'd be great if I could figure this one out because apart from this everything works very well.

Once I get this sorted out I'll try and write everything down!
Re: BIRT 2.5.1: IReportDocument.getPageNumber(bookMark) returns wrong page number? [message #514165 is a reply to message #514162] Fri, 12 February 2010 16:40 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Steve,

What happens when you set the page break interval to 20 on the toc list?

Jason

Steve van den Buys wrote:
> Well, testing seems to go pretty well with just one problem I can't
> really get my head around: page numbering is off by one page as soon as
> the actual table of contents itself jumps from 20 to 21 lines (so: it's
> correct when there are 20 or less lines and wrong from the moment there
> are more than 20 lines). Oddly enough the actual page break interval of
> the List that renders these lines is set to 30. So, I'm not sure what's
> going on here but it'd be great if I could figure this one out because
> apart from this everything works very well.
>
> Once I get this sorted out I'll try and write everything down!
Re: BIRT 2.5.1: IReportDocument.getPageNumber(bookMark) returns wrong page number? [message #514397 is a reply to message #513543] Mon, 15 February 2010 08:46 Go to previous messageGo to next message
Steve van den Buys is currently offline Steve van den BuysFriend
Messages: 9
Registered: February 2010
Junior Member
Jason,

if I set the page break interval to 20 it works but then I have an A4 page that is only filled for about two thirds of the page and then breaks to the next page to continue the table of contents. I'll experiment a bit more with the toc layout (looking at it now it seems a bit overly complex for what it has to do) to see if I can get BIRT to respect the actual page break interval...
Re: BIRT 2.5.1: IReportDocument.getPageNumber(bookMark) returns wrong page number? [message #514457 is a reply to message #513543] Mon, 15 February 2010 12:47 Go to previous messageGo to next message
Steve van den Buys is currently offline Steve van den BuysFriend
Messages: 9
Registered: February 2010
Junior Member
Hmm, simplifying the toc layout didn't solve the issue. So, currently page numbering is correct when the toc list has a page break interval of 20 but is wrong when I set it to anything bigger (30 is what I need to fill an entire A4 page).
Re: BIRT 2.5.1: IReportDocument.getPageNumber(bookMark) returns wrong page number? [message #1847808 is a reply to message #514162] Tue, 09 November 2021 04:21 Go to previous message
Padma Mugidi is currently offline Padma MugidiFriend
Messages: 1
Registered: November 2021
Junior Member
Could you please provide a blog or just documentation for the solution of TOC with page numbers. It will help more people
Previous Topic:Excluding Holidays
Next Topic:How to calculate xlsx columns width from page coordinates?
Goto Forum:
  


Current Time: Thu May 02 00:38:37 GMT 2024

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

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

Back to the top