[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

Hi,

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?

regards,
Ivo Roefs






<?xml version="1.0"?>

<st-source>
<time-stamp>From VisualWorks®, 7.8.1 of 4 januari 2012 on 15 augustus 2012 at 
19:50:49</time-stamp>


<class>
<name>Report4PDF_ReconstructionOfUnwantedPageBreaks</name>
<environment>Smalltalk</environment>
<super>Core.Object</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Model</category>
<attributes>
<package>Nectar-BookKeeping</package>
</attributes>
</class>

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


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

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

        self new start</body>
</methods>

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


<methods>
<class-id>Report4PDF_ReconstructionOfUnwantedPageBreaks</class-id> 
<category>services</category>

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

        page footer text: 
                        [:text |
                        text
                                right;
                                fontSize: 8;
                                string: 'page 
&lt;page&gt;/&lt;total&gt;']</body>

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

        (page header)
                marginTop: 10;
                table: 
                                [:table |
                                table row: 
                                                [:row |
                                                row cell: 
                                                                [:cell |
                                                                cell
                                                                        
widthPercent: 50;
                                                                        text: 
                                                                                
        [:text |
                                                                                
        text
                                                                                
                fontSize: 12;
                                                                                
                bold;
                                                                                
                string: 'Reconstruct unwanted page breaks']].
                                                row cell: 
                                                                [:cell |
                                                                cell
                                                                        right;
                                                                        
widthPercent: 50;
                                                                        text: 
                                                                                
        [:text |
                                                                                
        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
                                do: 
                                        [:index1 |
                                        page text: [:text | text string: 
'customer nr: ' , index1 displayString].
                                        page table: 
                                                        [:table |
                                                        table cellPadding: 2.
                                                        1 to: index1 \\ 20
                                                                do: 
                                                                        [:docNr 
|
                                                                        table 
row: 
                                                                                
        [: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>
</methods>

</st-source>

Other related posts: