chorme-pdf what is best practice for header and footer on long reports and page breaks before totals



  • What i am trying to accomplish is

    • pdf header and footer on each page
    • first page of report with title section
    • followed by report body with the page break in the table
    • the bottom of the table have totals in the table footer. (its repeating on each page now :( )

    when I try to use the sample with the group I get the error below

    Error "pdfCreatePagesGroup" was called with an undefined parameter

    Error while executing templating engine. "pdfCreatePagesGroup" was called with undefined parameter. One parameter was expected.
    logs:
    +0      Starting rendering request 75 (user: admin)
    +1      Rendering template { name: daily-account-balance, recipe: chrome-pdf, engine: handlebars, preview: true }
    +2      Data item not defined for this template.
    +2      Resources not defined for this template.
    +2      Executing script els_dbo_punter_account_balance using http-server strategy
    +127    Base url not specified, skipping its injection.
    +130    Replaced assets ["luckii_logo.png"]
    +130    Rendering engine handlebars using http-server strategy
    +191    Rendering request 75 finished with error in 191 ms
    Error: Error while executing templating engine. "pdfCreatePagesGroup" was called with undefined parameter. One parameter was expected.
        at handleError (/home/ubuntu/jsreportapp/node_modules/jsreport-core/lib/render/engineScript.js:94:22)
        at respondWrap (/home/ubuntu/jsreportapp/node_modules/jsreport-core/lib/render/engineScript.js:106:19)
        at module.exports (/home/ubuntu/jsreportapp/node_modules/jsreport-core/lib/render/engineScript.js:274:5)
        at IncomingMessage.<anonymous> (/home/ubuntu/jsreportapp/node_modules/script-manager/lib/worker-servers.js:279:47)
        at IncomingMessage.emit (events.js:327:22)
        at IncomingMessage.EventEmitter.emit (domain.js:529:15)
        at endReadableNT (internal/streams/readable.js:1327:12)
        at processTicksAndRejections (internal/process/task_queues.js:80:21)
    

    I have report header

    <body>
        <div>
            <div class="title ">
                <div class="img-container">
                <img src="{#asset luckii_logo.png @encoding=dataURI}" style="float:right;width:100px;height:100px;"> 
                </div>
            </div>
                        <h3>ELS Luckii.com</h3>
                        <h2>Daily Account Balance</h2>
                        <p>Report Date: {{now}}</p>                        
        </div>
        {{{pdfCreatePagesGroup accounts}}}
    

    Followed by the body of report.

    <table class="table striped table-border compact">
                <thead>
                    <tr >
                        <th>Account Id</th>
                        <th>Account Name</th>
                        <th align="right" >Bonus Balance</th>
                        <th align="right" >Cash Balance</th>
                        <th align="right" >Account Balance</th>
                    </tr>
                </thead>
                <tbody>
                    {{#each Account}}
                    <tr>
                         <td>
                            {{PunterId}}
                        </td>
                         <td>
                            {{AccountName}}
                        </td>
                        <td align="right">
                            $ {{numberFormat2 CurrentMinimumBalance}}
                        </td>
                        <td align="right">
                            $ {{numberFormat2 CashBalance}}
                        </td>
                        <td align="right">
                            $ {{numberFormat2 LastCalculatedBalance}}
                        </td>
                        </tr>
                    {{/each}}
                </tbody>
           
                <tfoot>
                    <tr>
                        <td>Totals:</td>
                        <td>_</td>
                        <td align="right">
                            Bonus: ${{total1 Account}}
                        </td>
                        <td align="right">
                            Cash: ${{total2 Account}}
                        </td>
                        <td align="right">
                            Balance: ${{total3 Account}}
                        </td>
                    </tr>
    
                </tfoot>
            </table>
        </div>
         <div style='page-break-before: always;'>
    </div>
    


  • resolved the group by pdf.

    still have an issue of the pdf header and footer and totals on every page.

    the report does not main inside the group

        <body>
            {{#each $pdf.pages}}
              {{#if 1}}
                <div style="page-break-before: always;"></div>
              {{/if}}
              <main class="main"> 
                <header class="header">             
                  {{#with (lookup ../$pdf.pages 1)}}
                    <h1>{{group}}</h1>
                  {{/with}}  
                </header>
                <footer class="footer">
                    <span>Page {{getPageNumber 1}} of {{getTotalPages ../$pdf.pages}}</span>
                </footer>
              </main>
            {{/each}}
        </body>
    </html>
    


  • Sorry about the learning curve

    Header and footer resolved

    Chrome pdf needed to have forced margin top, margin right, margin left, margin bottom.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.