When using jqueryprint.js to print from Firefox browser, an additional blank page appears before the content

Seeking assistance in printing a section of an HTML page using PHP with a large header space for empty space after printing. Despite multiple attempts, achieving the desired result in Chrome, but facing issues with Firefox, which adds an additional page before printing.

Why does Firefox insert an extra page with only the header when there is content or height set for the div or margin? The HTML code structure for printing is as follows:

    <section class="panel" id="payablePrint">
   <table>
    <thead >
      <tr>
        <th style="width:100%">
           <div id="print_header"style="opacity: 0.001;">
              (Content)
           </div>
        </th>
     </tr>
  </thead>
  <tbody>
     <tr>
        <td>
          <table style="width:100%">
            <tr>
               <th>Firstname</th>
               <th>Lastname</th> 
               <th>Age</th>
           </tr>
           <tr>
              <td>Jill</td>
              <td>Smith</td> 
              <td>50</td>
           </tr>
           <tr>
              <td>Eve</td>
              <td>Jackson</td> 
              <td>94</td>
           </tr>
    </table>
       </td>
     </tr>
    </tbody>
  <tfoot>
  <tr>
        <td>
           Footer content here...
        </td>
     </tr>
    </tfoot>
   </table>
   </section>
   <div class="row">
   <div class="col-lg-12 text-right">
     <button id="" onclick="printDiv('payablePrint')"  class="btn btn-shadow btn-primary jdIconButton"><i class="fa fa-print"></i> Print Agreement</button>
   </div>
</div>

CSS used for this structure:

 @media print{

 #print_header{
   display: block;
  }
  #Footer{
  display: none !important;
  margin-bottom: 0px;
  margin-top: 0px;
  }
  #printFooter {
  display: block;
  position: fixed; 
  bottom: 0px;
  left: 154px;
  }
 .panel-footer{
  border-top: none !important;
 }
 /* *************** */
 thead { display: block; page-break-after: avoid;page-break-before: avoid;}
 table { page-break-after:auto; }
 tr    { page-break-inside:avoid; page-break-after:auto; }
 td    { page-break-inside:avoid; page-break-after:auto; }
 thead { display:table-header-group; page-break-before: avoid;}
 tboby { display: table-row-group;page-break-after: avoid;page-break-before: avoid;}
 tfoot { display:table-footer-group;}
/* *************** */

 #footer {
  display: block; 
  position: fixed; 
  bottom: 0;
}
#companyName{
  margin-top: -10px !important; 
}
.panel-body{ 
  margin: -1mm 0mm 10mm 0mm !important;

}

.agreement_title{
  margin-top: -15px !important;
}
.margin_top{
  margin-top: -6px !important;
}

}

Issue with Firefox causing an extra page before printing despite being okay with no content. Any insights or solutions would be greatly appreciated.

Answer №1

To customize the layout, utilize colspan and rowspan accordingly. Eliminate the nested table within the main table. Take a look at the following code snippet for guidance.

    <section class="panel" id="payablePrint">
   <table>
    <thead >
      <tr>
        <th style="width:100%">
           <div id="print_header"style="opacity: 0.001;">
              Sample text for demonstration purposes only.
           </div>
        </th>
     </tr>
  </thead>
  <tbody>
     <tr>
        <td>
            content goes here ......
        </td>
     </tr>
   </tbody>
   <tfoot>
     <tr>
        <td>
           footer here....,.
        </td>
     </tr>
    </tfoot>
   </table>
   </section>
   <div class="row">
     <div class="col-lg-12 text-right">
      <button id="" onclick="printDiv('payablePrint')"  class="btn btn-shadow btn-primary jdIconButton"><i class="fa fa-print"></i> Print Agreement</button>
     </div>
   </div>

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

Utilizing a button's "data-" attribute to trigger a specific JavaScript function

I am trying to assign data to my buttons in a way that makes it accessible when clicked. While I can easily use JSON in a button's data attribute with a string as the key value, I am struggling to set the values to be a function instead. What I want ...

jQuery AJAX chained together using promises

In my current project, I am facing an issue where I have 4 get requests being fired simultaneously. Due to using fade effects and the asynchronous nature of these requests, there are times when empty data is received intermittently. To address this issue, ...

Hover over the first element to remove its class and replace it with a different element

I am attempting to develop a function that adds the class = "actived" to the first Element. This class has a CSS style that highlights the element in question. I have a list of 4 lines and I want the first one to automatically receive this class, while t ...

Issue with Bootstrap 4 progress bar malfunctioning in popover due to CSS property restrictions within the popover container

The following code functions correctly in the body area: <div class="progress" style="height: 25px;"> <div class="progress-bar" style="width: 30%;" role="progressbar" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100"> </div> & ...

How to use jQuery to dynamically assign a class to an li element

I'm attempting to use jQuery to add the 'block' class to specific li elements, but for some reason the class isn't being applied. The goal of the program is to display time slots and disable certain ones if they are blocked. Here's ...

What is the best way to implement this header style with code?

I came across this design from a potential client recently, even though we didn't end up working together. I thought it would be a good exercise to try coding the design for practice purposes. Just to clarify, this is not my original design and I have ...

Verifying the Absence of Events in the Chosen Month Display of the FullCalendar jQuery Plugin

Currently utilizing full calendar, which is being shown in month view with toggle buttons for navigating between months. Now, I am looking to have a message appear that reads "No events scheduled for the month." if there are no event objects present for t ...

Choose up to three elements using jQuery

DEMO I'm currently working on a project where I need to select only 3 items at a time. However, all the elements are being selected instead. Can someone please provide guidance on how to achieve this? "If a user wants to select another element, th ...

Ways to modify CSS using JavaScript

Can anyone assist me with a custom CSS code that I found? It looks like this: header.type-2:not(.fixed-header) nav>ul>li>a{ color:#000; } I've been trying to change the color to #fff using JavaScript, but haven't had any success yet. ...

Uploading files using HTML 5, Ajax, and jQuery

I am attempting to utilize jQuery to upload a file by using the ajax POST method and sending the uploaded file to url:"/files/uploads" with the parameter file. To achieve this, I have set up the following input elements: <form id="fileUploadForm"> ...

Tips for resolving issues with media queries in CSS

After deciding to create both desktop and mobile versions of my site, I attempted to utilize media queries in CSS. Unfortunately, after coding them, I discovered that they were not functioning as expected. Seeking a solution, I turned to Youtube where I ca ...

Element Style Does Not Align with Computed Z-Index

Currently, I am in the process of developing an HTML5 video player. However, I have encountered a problem where my custom controls become unclickable once the video element is set to fullscreen mode. This issue arises because the video's z-index is se ...

Achieving Full Height for Parallel Columns Divs with Bootstrap - A How-To Guide

I am struggling with getting two divs in parallel to have full height. Even though I have the divs side by side, when I try to set their height:100%;, nothing happens. What CSS properties do I need to modify to achieve this? The goal is to create a cove ...

Task: Choose MySQL option and Retrieve JSON data

I have a question regarding implementing a function in a separate module file and calling it within a route to retrieve query data: function getSobre() { return new Promise((resolve, reject) => { db.query(`SELECT * FROM sobre ORDER BY cod ...

Manipulating the size of a square using gestures and touch events for seamless resizing

I am trying to center a blue square with the ID #square both vertically and horizontally in my viewport on my iOS device... <div id="square"></div> #square { width:100px; height:100px; background:blue; margin:0 auto; } I want ...

Tips for establishing a universal onkeydown listener for all frames within a webpage?

Working with a complex legacy multi-frame webpage that needs to be compatible with IE-11 and responsive to hotkey events has brought up some challenges. It appears I can't simply declare a JavaScript method in the parent page. Rather, it seems that e ...

The rating and comment section is failing to adapt to smaller screens, creating a terrible user experience

I am a beginner with Sass and CSS. I wanted to create a rating and comment section which looks fine on a laptop screen, but appears off on smaller screens. It seems like the layout might be incorrect or maybe I didn't follow grid layout guidelines pro ...

Reposition HTML elements using JavaScript

Is there a way to use JavaScript or jQuery to replace the image with class "fnone" located under the span element with class "ddlabel"? <span id="flat_title" class="ddTitleText "> <img class="fnone" src="images/pinc.png"> <span ...

Obtaining the name of the image that has been uploaded using jQuery

//Image upload function $(function() { $(":file").change(function() { if (this.files && this.files[0]) { var reader = new FileReader(); reader.onload = imageIsLoaded; reader.readAsDataURL(this.files[0]); } }); }); function im ...

div layout; sidebar movements occur after appending div to the header

Having trouble mastering layouts, I am attempting to create a full-width header that includes a left sidebar and a right sidebar. The body is split into 5 sections: full width, left and right sidebars, center content with 3 columns, and the footer mirrorin ...