Tips for organizing elements onto separate pages for printing while avoiding overflow onto additional pages

I am encountering an issue while attempting to print tables and an image on separate pages.

Every time I print, an additional page spills over into a third page, causing overflow. How can I eliminate this extra space or overflow that results in a third page when printing?

I have previously tried adding page breaks before and after in various locations to resolve this problem, but have not been successful.

Since the tables change in size due to the data they contain, but never exceed a page, the image on the second page needs to accommodate this variability while remaining on the second page. I have struggled with this issue. I attempted using absolute positioning to keep it fixed, but it still shifts when the table size changes, sometimes extending to a third page.

Any suggestions or advice would be greatly appreciated. Thank you.

HTML:

<body>

<!-- The table content is inserted here -->

<hr class="break">

<div class="second">
    <img src="/vessellog.png" class="dlog">
</div>

</body>
</html>

CSS:

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" type="text/css" href="styletable.css">
  <style>

    table tbody tr:not(.no-counter) {
        counter-increment: rowNumber;
    }

    table tbody tr:not(.no-counter) td:nth-child(1)::before {
        content: counter(rowNumber);
        min-width: 1em;
        margin-right: 0.5em;
    }

    .headingTable {
        height: 150px;
        font-size: 12px;
        width: 100%;
    }

    .tableWrapper {
        width: 100%;
        border-collapse: collapse;
    }
    .second {      
        transform: rotate(270deg);
        margin-left: 180px;
        margin-top: -60px;
        width: 720px;
        height: 1080px;
        position: absolute;
    }

    .dlog {
        max-width: 100%;
        max-height: 100%;
    }

    .break {
        page-break-after: always;
    }
  </style>
</head>

Answer №1

After encountering an issue, I found a solution by inserting the following code:

<div style="page-break-before:always;"> </div>
right after the last <table> on the initial page. This simple addition effectively created the necessary page break for separate printing. Here's the snippet:

</table> /* End of First Page */
<div style="page-break-before: always;"> </div> 

<div class="vlogimage"> /*Second Page*/
    <img class="logologext" alt='<#Business_name>' src= "<#servername>/<#Register_Directory>/<#Splash_Logo>?v=<#now format='yy-mm-dd-hh-nn'>">
    <p class="vlogtext"><#Business_name> Daily Vessel Log</p>
    <img src="/vessellog.png" class="dlog" >
</div>

Attempting to apply page-break-before: always; to the first <div> on my second page did not yield the desired outcome.

Perhaps this solution will be beneficial to others facing a similar issue!

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

Error encountered while attempting to save HTML table data as text in MySQL due to SQL syntax

Query for adding text to the database: INSERT INTO uri VALUES('') I encountered the following syntax error: 'MySql.Data.MySqlClient.MySqlException' was found in MySql.Data.dll You have an error in your SQL syntax; please refer to t ...

Calculate the number of input boxes that have been filled

<input type="number" name="day1"> <input type="number" name="day2"> <input type="number" name="day3> Can anyone help me figure out how to count the number of filled fields in this form? For example, if only day1 is filled, the count resu ...

Adjust the height of the tabs bar in the Guake terminal

Is there a way to reduce the height of the tabs bar in the Guake terminal? I found a solution for GNOME terminal on this post, where they mentioned editing ~/.config/gtk-3.0/gtk.css. Is there a similar method for achieving this in Guake terminal? ...

Modifying the color of the error icon in Quasar's q-input component: a step-by-step guide

https://i.stack.imgur.com/4MN60.png Is it possible to modify the color of the '!' icon? ...

Looking to generate an HTML table using JavaScript?

Similar Question: Create HTML table from a Javascript array I have received an array that looks like this var univArray = new Array( {name: "Stanford University", nick: "Stanford", ownership: "private", sys: "n/a", SATh: 1550, SATl: 1360, tui ...

What is the best way to dynamically validate the fields and generate an array?

Currently in my Angular application, I've successfully implemented a pivot table using pivot.js. Now, I am faced with the task of loading all the indexes from elastic search whenever the user switches the index. Once the index is changed, the corresp ...

Position Bootstrap buttons to the right side

I am looking to reposition the buttons in the header, shifting them from the default right side to the left side. Specifically, I want to move Abcd to the right side and have A1, A2, A3, A4, and A5 displayed on the left side. Here is my current code: < ...

What is the best way to add a new div below a specific div without disrupting the existing layout of other elements on the page?

Is there a way to create a new div that appears below a specific div on a webpage, but is displayed above all other elements without affecting their positioning? Here is an example: --------------------------------------------- | | ...

Concealing excess background color in HTML/CSS

I'm currently experimenting with adding a background color shape, such as a large rotating div, to the background of my website. However, I've encountered an issue where placing this background in the desired location is causing a large margin to ...

Searching for effective methods to deliver reset password notifications to users

Seeking advice on sending password reset emails to users who have forgotten their passwords. Interested in various suggestions and methods for implementing this feature. I have a simple script that prompts users to click a 'forgot password' link ...

The dropdown height feature is experiencing issues in the Chrome browser

3 radio buttons and a single select box are displayed on the page. When clicking on the first radio button, the select box should show contents related to the first radio button. However, when selecting the second or third radio buttons, the select box hei ...

Tips on minimizing the vertical size of a mat field housing a mat-select dropdown

I need help reducing the height of a mat field that includes a mat-select in Angular v15. The code is directly from the material components documentation, with no alterations. It consists of a default table and default outline formfield. <mat-form-fi ...

Header width does not fully occupy the available space

I'm working on a table that includes a div element for adding a header to it. <div class="table-responsive"> <table class="table"gt; <thead> <div class="topPic"><span><i class="fa fa-tree fa-2x"></i>< ...

Building Nested Divs with JavaScript

I've encountered an issue with this code snippet. While it works perfectly fine in jsfiddle, I faced a problem when testing it on my local file. Only the first three lines created by html are displayed: test h1 test h2 test p (I tested the code ...

To view the contents of the dropdown list on an iPhone, simply tap the arrow key next to the mobile dropdown list and the contents will be

I am attempting to trigger the dropdown list contents to open/show by tapping on the arrow keys near AutoFill on the iPhone mobile keyboard. This action should mimic clicking on the dropdown itself. Currently, I am working on implementing this feature for ...

Tips for adjusting the width of items within the Box element in Material UI React

I am utilizing React Material UI along with the Box component to style my form. In this scenario, I have 4 items in each row except for the last row where I need to display only 3 items with the last item filling the entire row by merging two elements toge ...

What could be the reason for the child element not occupying the full height of its parent container?

* { padding: 0; margin: 0; box-sizing: border-box; } body { margin: 50px; } .navbar { display: flex; align-items: center; justify-content: center; color: darkgreen; font-family: 'Vollkorn', serif; font-size: 1.2rem; font-w ...

Creating a rotating gallery with jQuery that can be navigated both forwards and backwards

Currently, I have a jQuery gallery that allows users to view images by moving forward only. What I'm looking for is a way for the user to click on the right side of the image to move to the next one and on the left side of the image to go back to the ...

How can I make the hover effect only apply to the text and not the entire box?

I'm wondering how I can make the :hover property only affect individual letters in my navigation bar, instead of hovering over the entire box. * { margin: 0px; padding: 0px; } .navigation-bar { height: 3.2em; background: gray; text-align: ...

Does embedding an Iframe for external files from your server enhance the loading speed of the current page compared to directly loading it on the page?

I'm facing an issue with the loading time of a Facebook post on my webpage index.php. The current method of using the embedded post provided by Facebook is taking too long to load. My solution is to create a separate page, post.php, where only the Fac ...