gb.Report 2 print only first page

Post

Posted
Rating:
#1 (In Topic #1568)
Trainee
 Good morning everyone

I created a report using the gb.report2 component.

I created two sections: one for the first page, which displays various report information and the beginning of the report data, and a section 2 that displays a header and the remaining data in a ReportVBox, along with information and a footer.
Everything works fine when the report consists of multiple pages, but when there's little data to print, the first page (first section) prints correctly, but the second page also prints with the header and footer of Section 2.

The question is: How can I print only the first section?

I want to clarify that I had to create the second section (Section 2) only because, when the ReportVBox for Section 1 is filled beyond the available space on the first page, it starts printing directly from the second page. Obviously, the fixed property on ReportVBox is true.
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’

rhoct said

Good morning everyone

I created a report using the gb.report2 component.

I created two sections: one for the first page, which displays various report information and the beginning of the report data, and a section 2 that displays a header and the remaining data in a ReportVBox, along with information and a footer.
Everything works fine when the report consists of multiple pages, but when there's little data to print, the first page (first section) prints correctly, but the second page also prints with the header and footer of Section 2.

The question is: How can I print only the first section?
I'm trying to comprehend what you want to achieve here.
If I understand correctly:
If so little data, that section 1 (page 1) can contain all data, you do NOT want section 2 (page 2) shown, as it is empty?
Is my understanding of that correct?

A simplified sample report source archive to look at would help so I can see what you try to achieve and how you are approaching it.
I know it can take some fiddling with to get it working the way you want and there is some stuff not quite working as should (and reported as bug quite a while ago).
That is why a simplified example helps, as I can fiddle with it  ;)

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#3
Trainee
 Attached is the Lorem Report project, found in the examples, modified by me to emulate my problem.
In report1.report there are two sections, the first is called "Cover" and the second "Book".
If you run the project, two pages will be created, the second of which is blank.
The problem is how to prevent the second page from being created since it is blank, and more generally, how to prevent the "Book" section from being generated.
Thanks in advance

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’

rhoct said

Thanks in advance
I'll have a look at it and get back to you.

Did you know that when you have an opened project in IDE you can create a source archive from there (and it's no zip files for sure).
In an opened project in IDE press:

Code

Ctrl + Alt + A
or click menu Project -> Make source archive…

Easy as that..  ;)

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#5
Trainee
 Thanks for the tip. I rarely share source code.

The individual sections (class _ReportSection) are accessed by indexing the report, for example, within the report class -> me[0], but there's no property that allows you to not create a section in the output file.
Wait for your reply.
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’

gbWilly said

I'll have a look at it and get back to you.
I have never seen this example before. I use reports a lot but completely differently, as I read data from databases and mostly use the data event.

I have run into  a situation where I also wanted not to show a page if no data was there. I eventually reported this as a bug and created a workaround in the form of 2 reports (a 1 page and a multiple page) and first check if there is data and then determine what to show. It works, but not how it should be as in gb.report (predecessor of gb.report2) this used to work (in my case). It was when migrating to gb.report2 that I ran into this trouble, hence the bug report (in okt 2024!!).

I have tried a few things (as I did once with my problem) and testing if there is data or not can be easily done, telling in code not to show something is easily done, but the rendering of the documents, seems not to pick up on that somehow  :?

I added code to test if there is data first and next I tried:

1. Set Report1 count to 1.

Code (gambas)

  1. Public Sub Report_Open()
  2.  
  3.   ...
  4.  
  5.   ss = Split(sBook, "\n", Null, True)
  6.  
  7.   If ss.Count > 0 Then
  8.   ' For Each s In ss
  9.   ' ...
  10.   ' hRepIm.Image = Image.Load("./caduceus.jpg")
  11.   Else
  12.     Report1.Count = 1
  13.  
  14.  

2. Make book invisible.

Code (gambas)

  1. Public Sub Report_Open()
  2.  
  3.   ...
  4.  
  5.   ss = Split(sBook, "\n", Null, True)
  6.  
  7.   If ss.Count > 0 Then
  8.   ' For Each s In ss
  9.   ' ...
  10.   ' hRepIm.Image = Image.Load("./caduceus.jpg")
  11.   Else
  12.     Report1[1].Visible = False
  13.  
  14.  

3. Make all on book invisible.

Code (gambas)

  1. Public Sub Report_Open()
  2.  
  3.   ...
  4.  
  5.   ss = Split(sBook, "\n", Null, True)
  6.  
  7.   If ss.Count > 0 Then
  8.   ' For Each s In ss
  9.   ' ...
  10.   ' hRepIm.Image = Image.Load("./caduceus.jpg")
  11.   Else
  12.     ReportVBox1.Visible = False
  13.     ReportPanel1.Visible = False
  14.     ReportLabel2.Visible = False
  15.  
  16.  
None of above worked  :(

So, the problem remains and I have no solution but doing a workaround by testing data for content first and then open one of two possible reports.
Maybe someone else can shed more light on the issue.

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#7
Trainee
 I don't like this component; it's quite unstable and inflexible, and right now I don't feel like studying the entire source code to fix it.
For now, I'm thinking of using a double report, one for a single page and one for two or more. In a few days, I'll use Cairo to rewrite the report generator.
Online now: No Back to the top

Post

Posted
Rating:
#8
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’

rhoct said

I don't like this component; it's quite unstable and inflexible, and right now I don't feel like studying the entire source code to fix it.
For now, I'm thinking of using a double report, one for a single page and one for two or more. In a few days, I'll use Cairo to rewrite the report generator.
I get what you mean. I use it at some places but at other places I use cairo to create a pdf.
Seems, we're on the same page  ;)

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#9
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’

rhoct said

I don't like this component; it's quite unstable and inflexible, and right now I don't feel like studying the entire source code to fix it.
There is hope on the horizon as I got Fabien (developer of gb.report2) to pick up the bug again and he seems to have found the problem.
See screenshot with latest bug report conversation on the topic.
Image

(Click to enlarge)

There is hope for a solution  ;)

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#10
Trainee
 Thanks for your support.

I solved the problem by using the events raised to read the data into the ReportLabel, but only because it's a simple table. In another report, when I needed to dynamically insert objects into a ReportVbox, I had to use the first page (first section) as the cover page and the other pages using a different section.

In any case, the visibility issue isn't just related to visible/not visible, but also to incorrectly generating some objects in the report if an object isn't visible.
Online now: No Back to the top

Post

Posted
Rating:
#11
Avatar
Enthusiast
Gianluigi is in the usergroup ‘Enthusiast’
Attachment

CoverReportOC-0.0.4.tar.gz

Hello,

I apologize if my first post is about an old issue that you've already resolved.  :$
Fabien Bodard is also working on the component.
I hope he takes old projects into account.
First of all, I always have a hard time understanding issues, so please excuse me if I misunderstood your question.
I'm attaching an example report that simulates a offer and should do what you asked.
I put it together using a few things here and there, and it only works with euros.
If you load data from a database, also look at the ReportTest example on the farm.
On this page (it's in Italian, but if you use a translator…) I tried to explain what the farm examples do:
Creare report con il componente gb.report2 - Gambas-it.org - Wikipedia

Last edit: by Gianluigi

Online now: No Back to the top
1 guest and 0 members have just viewed this.