Printing Multiple Pages Using JavaScript and Cascading Style Sheets

Encountering difficulties displaying page numbers when printing multiple multipage reports

Here is the provided HTML Format :

<style type="text/css> body {
  counter-reset: report 1 page 0;
}
td.footer:after {
  counter-increment: page;
  content: "Page " counter(page)" of Report " counter(report);
}
.rowLabel3 {
  counter-reset: page 0;
  counter-increment: report
}
</style>
<table>
  <thead style="display: table-header-group;">
    <tr>
      <th>Report Specific Header Contents which needs to come on every page we are displaying report</th>
    </tr>
  </thead>
  <tbody style="display: table-row-group;">
    <tr>
      <td>Some Data</td>
    </tr>
    ...
    (more rows)
  </tbody>
  <tfoot style="display: table-footer-group;">
    <tr>
      <td class="footer">

      </td>
    </tr>
  </tfoot>
</table>

<div class="rowLabel3" style="page-break-after:always;">*** END OF REPORT ***</div>

... (repeat for additional tables and data)

While implementing Tfoot to appear on each page, it fails to increment the section correctly.

The current approach involves counting the number of rows and adding an extra row after a certain threshold. However, this method is inconsistent across different reports.

Answer №1

This is how it functions:

body {
    counter-reset: report 1 page 0 ;
}

td.footer:after {
    counter-increment: page;
    content: "Page " counter(page) " of Report "  counter(report);
}
.rowLabel3{
  counter-reset: page 1;  
  counter-increment: report
}

I made modifications to @page and rebranded it.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

limitations on passing url parameters in react.js

Currently, I am facing an issue with passing URL parameters in my React.js web app. For illustration purposes, here is a snippet of the routes: import React from "react"; import {BrowserRouter, Route, Switch, Redirect} from 'react-router-dom'; ...

Activate a function for a targeted ajax request within a global $.ajax event

I have a series of 3-4 ajax calls that are scheduled to be executed at some point. In one of these calls, I want to activate a function on the global ajaxSend event. This particular ajax call may not be the first or last in the sequence. However, when I at ...

"The Promise in the AngularJS Karma test specification did not resolve and the .then() method was not invoked

An issue arises when attempting to perform AngularJS Karma Unit Testing on a service. The service includes a method like the one below: service.getIntersectingElements = function (element, elements) { var deferred = $q.defer(); var tolerance = 20 ...

What is the process for customizing the color and thickness of the active tab inkBarStyle in React Material-UI?

Check out this inquiry: How can I change the color of the active tab in MUI? And for a potential solution, have a look at this response: The provided answer seems to be effective: <Tabs inkBarStyle={{background: 'blue'}}>... However, I a ...

Navigate directly to a designated element in a React component without the need to scroll when clicking a link

When viewing a user's profile in React, clicking on an image currently scrolls to that specific image within the entire images page. However, I am looking to modify this behavior so that it navigates directly to the image element without any scrolling ...

Combining CSS and JS files for accordion list - experiencing issues when used separately

Recently, I've been trying to create an accordion list and stumbled upon some code (HTML, CSS, and JS) on www.w3schools.com. When I have the code all in one document and run it as a single .html file, everything works perfectly. However, when I split ...

how to dynamically update a button's text using Vue.js

I have a challenge where I need to dynamically change the text of a button based on whether a value is true or false. Below is the code snippet that I have been working on: <button class="btn btn-primary table-button" type="button&quo ...

TypeError: Unable to access the 'classify' property of an object that has not been defined (please save the ml5.js model first)

In my React app, I have set up ml5.js to train a model by clicking on one button and make predictions with another. However, I encounter an error when trying to test the model for the second time: TypeError: Cannot read property 'classify' of und ...

Tips for successfully utilizing hyphens when passing an object property as an argument

Does anyone know how to pass an object property with a hyphen in it as an argument? I'm having trouble with this issue. Object { "section-id": 1, ... } HTML <div *ngFor="let section of sections" (trackScrollLeave)="leave(section.sectio ...

What is the best way to showcase two SVG clocks on a single webpage?

The issue arises when combining the desktop and mobile versions of the clock script. The first clock works fine on its own, but upon duplicating another set of scripts for the second clock, it encounters display problems. I have appropriately labeled the c ...

How can I retrieve the attributes of multiple identical components within a webpage?

I've recently delved into learning Vue and decided to create a small application for adding fractions together. I have developed two main components: Fraction.vue and App.vue. The App.vue component contains multiple instances of the Fraction component ...

Retrieving the date from the final item in a JSON object using AngularJS

In my web application built with AngularJS, I am dynamically creating objects. The goal is to allow users to load new events by clicking a button. To achieve this functionality, I need to determine the date of the last event loaded so that I can fetch the ...

Using PHP to ascertain the requested dataType or responseType from the client

My ajax request is fairly simple: $.post('server.php',data, function (json) {console.log(json)},'json'); I have configured jQuery to expect json data based on the dataType setting. Question: Is the dataType parameter equivalent to re ...

Using React refs to target multiple elements dynamically with the help of the map

My code effectively catches when the dropdown is clicked outside, and it's working well: displayOptions() { return _.map(this.props.selections, (option, index) => { return ( <div className="ui icon top dropdown" ...

The font remains the same despite the <Div style=> tag

I have a script that loads external HTML files, but I am facing an issue with changing the font to Arial. The script is as follows: <script type="text/javascript"> $(document).ready(function(){ $("#page1").click(function(){ ...

Clear session data when logging out from a dropdown list

I have a header that appears on several of my web pages. It contains a dropdown menu that allows users to log out by selecting the "Logout" option. When a user clicks on "Logout", I want to destroy the session variables associated with their session. Is t ...

Align the middle element in a dynamic row

There is a row consisting of three elements: left, center, and right. However, the problem lies in the fact that the center element is not aligned at the screen level, but rather at the row level. Is there a solution to align this element at the screen l ...

Having difficulty adjusting the margin-top for the menu div

Why am I unable to apply margin to my a links within the div identified by id="menu". I can successfully implement margin-left, but when attempting to use margin-top or margin-bottom, it does not work as expected. I wish to adjust the position o ...

A guide to transferring modules between component files in JavaScript

My query pertains to the handling of imports in web pages. When a file is imported into another, do the declarations and imports from the imported file become available in the file where it is being imported? A suggestion was made for me to import a compo ...

What is the best way to achieve maximum height?

Currently, I am attempting to obtain the total height of the page in order to apply it to the styles, specifically for the darkMask class. The reason for needing this height is that when a certain action is triggered within the header, a dark overlay is a ...