[pdf4st] Re: unwanted page breaks

  • From: Ivo Roefs <ivo.roefs@xxxxxxxxx>
  • To: pdf4st@xxxxxxxxxxxxx
  • Date: Wed, 15 Aug 2012 19:55:14 +0200

Hello Bob,

Thanks for the swift response.
I tried some debugging using the methods you described but I can't figure it out.
Attached you can find a fileout of a class which reproduces the problem, starting from page 4.

I also discovered a second minor problem. The alignment in the footer is 'right', but apparently there still some extra space on the right side of the page numbering.

If you could find the time to look into this, it would mean a lot to me.

kindest regards,
Ivo Roefs

Op 15/08/2012 14:52, bobn@xxxxxxxxxx schreef:
Hello Ivo,
Nice to see Report4PDF being used. 

The cell page break code checks to see if a cell will fit on the current page, given where the current Y value is, using #checkFitSpacingTop: 
If the cell is too tall, a page break is triggered. So the interesting question is why was the cell considered too tall for the remaining page height. 
Since you know which page has the first problem, you can put a conditional break which checks the #currentPageNumber in R4PBuilder>>buildCell: just prior to  #checkFitSpacingTop:

The #resetCurrentYAfter: wrapper method is used to go back to the previous Y value after a cell is done being built. That way the next cell is a row is placed in the correct vertical position.
You can send #traceToTranscript or #traceToFile: to the report to see what the output is. The trace shows the calculated page height which is used by R4PCell>>canBuildAt:limit: 

If you can generated an example that causes the problem I'd be happy to look into it.

Hope you find this helpful, 
Bob Nemec

From: Ivo Roefs <ivo.roefs@xxxxxxxxx>
To: pdf4st@xxxxxxxxxxxxx
Sent: Wednesday, August 15, 2012 5:58:11 AM
Subject: [pdf4st] unwanted page breaks


I've been exploring Report4PDF (PDF4Smalltalk)....This looks very promising indeed.
I'd like to congratulate the people who put all their effort into it.

I bumped into a small problem.
As you  can see (hopefully) in this screenshot...after 12 pages of correct behaviour.... suddenly there's an unexpected page break after the first cell.
Also for the next three columns there's this unexpected page break.
It appears that with the problematic cells, that they start slightly higher than on other pages.
After that everything's fine again for a number of pages, and then the same problem gets repeated.

I've been looking into some methods like, #checkFitSpacingTop:   #findPageToFitRowTop:, but I really don't know what to look for.

Can anyone give any pointers what could be wrong here?

Ivo Roefs

<?xml version="1.0"?>

<time-stamp>From VisualWorks®, 7.8.1 of 4 januari 2012 on 15 augustus 2012 at 


<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->

<class-id>Report4PDF_ReconstructionOfUnwantedPageBreaks class</class-id> 
<category>instance creation</category>

<body package="Nectar-BookKeeping" selector="start">start

        self new start</body>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<body package="Nectar-BookKeeping" selector="footerOn:">footerOn: page

        page footer text: 
                        [:text |
                                fontSize: 8;
                                string: 'page 

<body package="Nectar-BookKeeping" selector="headerOn:">headerOn: page

        (page header)
                marginTop: 10;
                                [:table |
                                table row: 
                                                [:row |
                                                row cell: 
                                                                [:cell |
widthPercent: 50;
        [:text |
                fontSize: 12;
                string: 'Reconstruct unwanted page breaks']].
                                                row cell: 
                                                                [:cell |
widthPercent: 50;
        [:text |
                fontSize: 12;
                string: 'PDF4Smalltalk &amp; Report4PDF Rocks!!!!']]]]</body>

<body package="Nectar-BookKeeping" selector="start">start
        "Report4PDF_ReconstructionOfUnwantedPageBreaks start"

        | report |
        report := Report4PDF.R4PReport new.
        report A4Portrait.
        report margin: 0.
        report page: 
                        [:page |
                        page margin: 10.
                        self headerOn: page.
                        1 to: 50
                                        [:index1 |
                                        page text: [:text | text string: 
'customer nr: ' , index1 displayString].
                                        page table: 
                                                        [:table |
                                                        table cellPadding: 2.
                                                        1 to: index1 \\ 20
        [:row |
        row fontSize: 6.
        row cell string: 'cell1OfDocNr' , docNr displayString.
        row cell string: 'cell2OfDocNr' , docNr displayString.
        row cell string: 'cell3OfDocNr' , docNr displayString.
        row cell string: 'cell4OfDocNr' , docNr displayString]]]].
                        self footerOn: page].
        ^report saveAndShowAs: 'test.pdf'</body>


Other related posts: