PDF Generating Tool Support Forum

HOME   Login   Register    Search




  Subject: How to find out if a page break has occurred
   PostPosted: 26 May 2011, 10:50 
i'm having big trouble to implement a simple customer request: in a report that includes data concerning some countries, the customer wants the country name as a headline, and if the data of one country spreads over several pages, the customer wants the headline to be changed to "Country name (continued)".
Now i have no clue how to implement that (tbh, at the moment i'm counting the printed lines of the report and manually adding the pagebreaks, but that is not the most stable solution)

I'll give an (dummy) example of the report (Top Car Sales per Country)

-- REPORT START --
Italy
- Fiat 500

Germany
- Audi A1
- BMW 3

-- PAGE BREAK --

Germany (continued)
- VW Golf
- Skoda Fabia
- Dacia Logan

-- PAGE BREAK --

Switzerland
- Dunno
- Foo

Austria
- Bar

--PAGE BREAK --

Austria (continued)
- Some other thing


  Subject: Re: How to find out if a page break has occurred
   PostPosted: 05 Sep 2011, 10:21 
After doing a lot of thinking (and having solved the problem by "guessing" the size of the content before it is beeing passed to pd4ml), i think a possible solution would be to implement a feature that makes it possible to define two page headers, one for "the next pagebreak", and one for "the pagebreaks after that".

Any thoughts about that?


  Subject: Re: How to find out if a page break has occurred
   PostPosted: 06 Sep 2011, 12:48 
PD4ML can repeat a table header after a page break (pd4ml.enableSmartTableBreaks(true)). But it does not allow to add, for example, "(continued)" to the original header. So probably the trick with table headers will work for you.

PD4ML Pro allows you to define page-specific headers in a case you use <pd4ml:page.header> tag.

1. The tag supports scope attribute. For example: scope="1" defines header for the first page only; meaning of scope="2+", scope="4-5" is hopefully obvious. On the top of HTML page you may define multiple <pd4ml:page.header> tags with different scope attribute values.

2. Also <pd4ml:page.header> without scope attribute may appear somewhere in the document body. In the case it impacts all subsequent pages (until it is overridden by another <pd4ml:page.header> tag)

For your sample in theory it should be like that:
Italy.
<hr>
<pd4ml:page.header>
Italy (continued)
<hr>
</pd4ml:page.header>
item<br>
item<br>
item<br>
item<br>
item<br>
item<br>
item<br>
item<br>
<pd4ml:page.header></pd4ml:page.header>
<p>&nbsp;<p>


However I tested the code and it does not work as desired. In a case of multiple header definitions/redefinitions on a single page only the last header definition takes effect. We'll check if it possible to improve the algorithms to support the above idea.


  Subject: Re: How to find out if a page break has occurred
   PostPosted: 08 Sep 2011, 08:29 
That's excellent news!
I'll check the version log now and then to see if i can refactor my quite bad solution.


  Subject: Re: How to find out if a page break has occurred
   PostPosted: 08 Sep 2011, 08:52 
Guest wrote:
I'll check the version log now and then to see if i can refactor my quite bad solution.

  • Drink coffee
  • Boot brains
  • Post in forums


  Subject: Re: How to find out if a page break has occurred
   PostPosted: 16 Nov 2011, 18:30 
I think I've found a solution: avoid having to know about the pagebreaks.
The trick is to unset/set the page headers the way shown to prevent having the country name printed twice.
The issue reported in this thread (multiple page headers) is fixed in version 3.8.

I will not adapt the example to fit the older examples :)

Code:
<table style="page-break-inside: avoid;">
    <pd4ml:page.header> 
    </pd4ml:page.header>
       <tr>
          <th>Italy</th>
       </tr>
       <tr>
          <td>Item 1</td>
        </tr>
  </table>
     <pd4ml:page.header>
     <table>
    <tr>
       <th>Italy (Continued)<br>Company 1</th>
    </tr>
    </table>
    </pd4ml:page.header>
    <table>
    <tr>
       <td>Item 2</td>
    </tr>
   ...
</table>
<pd4ml:page.header>
     <tr>
         <th>Italy (Continued)</th>
   </tr>
    </pd4ml:page.header>
   <table style="page-break-inside: avoid;">
       <tr>
          <td>Company 2</td>
       </tr>
       <tr>
          <td>Item 1</td>
      </tr>
   </table>
     <pd4ml:page.header>
     <table>
    <tr>
       <th>Italy (Continued)<br>Company 2</th>
    </tr>
    </table>
    </pd4ml:page.header>
    <table>
    <tr>
       <td>Item 2</td>
    </tr>
   ..
</table>


Output:
Italy
Company 1
Item 1
Item 2
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8
Item 9
<<pagebreak>>
Italy (Continued)
Company 2
Item 1
Item 2
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8
Item 9
<<pagebreak>>
Italy (Continued)
Company 2
Item 10
Item 11
Item 12
Item 13
Item 14
Item 15
Item 16



[Reply]     [ 6 posts ] 

cron
Copyright ©2004-10 zefer|org. All rights reserved. Bookmark and Share