When I print a specific A4 format division containing content as a pdf, I noticed that there is excess white space above the content on the second and third pages. I am curious

Feeling a bit frustrated here, I've tried everything but my project seems to break whenever I try to print 3 pages as a PDF and enter the printing dialog.

If you'd like to check out the pages directly, click this link. Pressing cmd shift P will open the printing dialog where the issue occurs.

I've gone through debugging to see if any of the elements are causing the problem, but it doesn't seem to be the case. This appears to be a global issue, and I can't figure out what's going wrong.

Here is the code for the print media query:

@media print {
  body {
    -webkit-print-color-adjust: exact;
  }

  html, body {
    height: auto;    
  }

  .wrap {
    padding: 0;
  }

  .invoice-paper {
    page-break-after: auto;
    position: relative;
    display: block;
    padding: 40px;
    margin: 0;
    width: 210mm;
    height: 297mm;
    box-shadow: initial;
  }

  .invoice-paper:last-child {
    page-break-after: auto;
  }

}

This is the HTML inside the body tag:

<div class="wrap">
  
  <div class="invoice-paper">
    <?php include 'components/header.php'; ?>
    <?php include 'components/first-tape.php'; ?>
    <?php include 'components/second-tape.php'; ?>
    <?php include 'components/third-tape.php'; ?>
    <?php include 'components/usps.php'; ?>
  </div>

  <div class="invoice-paper">
    <?php include 'components/icp-intro.php'; ?>
    <?php include 'components/icp-segment.php'; ?>
    <?php include 'components/quote.php'; ?>
    <?php include 'components/buyer-persona.php'; ?>
  </div>

  <div class="invoice-paper">
    <?php include 'components/quote-2.php'; ?>
    <?php include 'components/graph.php'; ?>
    <?php include 'components/quote-inverted.php'; ?>
    <?php include 'components/teaser.php'; ?>
  </div>

</div>

https://i.sstatic.net/0CxC3.png

https://i.sstatic.net/30Z73.png

Answer №1

After some investigation, it seems that the issue was caused by the "gap: 4rem;" setting pushing the content downwards. Although I have managed to resolve this particular problem, I am now faced with a new challenge of having four pages with one being empty.

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

Struggling to get collapsible feature functioning on website

I'm trying to create a collapsible DIV, and I found a solution on Stack Overflow. However, I'm having trouble getting it to work on my website. I created a fiddle with the full code, and it works there. But when I implement it on my site, the con ...

Elements shifting positions based on the size of the window

I am facing an issue with positioning the register form on my website. I want it to be fixed at the bottom-right corner of the window, without reaching the top. Although I managed to achieve this, the problem arises when the screen resolution changes. For ...

JQuery Anchor Link Scrolling Problem on Specific Devices

I'm having an issue where my webpage does not scroll correctly to an anchor when a link is clicked. The problem arises from the header size changing based on the viewport width. While it works fine in desktop Chrome, in the mobile version the header h ...

Tips for adjusting the width of the scrollbar track (the line beneath the scrollbar)

How can I style a scrollbar to match this specific design? https://i.stack.imgur.com/KTUbL.png The desired design specifies that the width of -webkit-scrollbar-thumb should be 5px and the width of -webkit-scrollbar-track should be 2px. However, it is pro ...

Adjust the position of elements based on their individual size and current position

I am faced with a challenge regarding an element inside a DIV. Here is the current setup... <div id="parent"> <div id="child"></div> </div> Typically, in order to center the child within the parent while dynamically changing i ...

The background image on my website isn't showing up once it's been deployed via GitHub

I've tried various solutions to fix the issue at hand, but unfortunately, none of them seem to be effective. I double-checked the image path directory and confirmed that it is accurate. Even after uploading both png and jpg files, the problem persists ...

Running a JavaScript file enclosed within an AJAX response

I have a web application built with HTML5 that utilizes jquery 3.2.1. Within the application, there is a search feature that makes an ajax request. The response from this request includes HTML code, which contains a <script> tag linking to a js file ...

Implementing a switch to trigger a JavaScript function that relies on a JSON object retrieved from a GET request

Having some trouble using a toggle to convert my incoming Kelvin temperature to Celsius and then to Fahrenheit. It loads properly as default Celsius when the page first loads, but once I try toggling the function outside of locationLook, it doesn't se ...

Tips for implementing a single function across multiple HTML classes using JavaScript

For the past few days, I've been struggling with a JavaScript issue as a newcomer to the language. $(document).on('click', '.content-click', function(){ $(".content-click span").toggleClass("clicked"), $(".content-view") ...

Is it possible to implement custom classes in @apply within a SCSS file in a Tailwind Next.js project?

Having trouble implementing a custom class overflow:inherit as @apply overflow-inherit in my next.js project with tailwind. It seems to be causing an error. Strangely, I can successfully use pre-built tailwind classes like @apply flex flex-col md:h-full h- ...

Creating a notification for specific choices in a dropdown menu

I am working on a form that includes a select element with multiple options. Depending on the option selected, a different form will be displayed. My concern is if a user starts filling out one form and then decides to select another option, I want to add ...

Tips on positioning only one list item on your Bootstrap navbar to the right

I am currently learning to code with HTML and am attempting to create a navigation bar with some list items on the right side and some on the left. Although I'm using Bootstrap, I am unable to figure out how to move only the 'contact' item t ...

How to integrate video into HTML code using JSON wrapping in iOS app development for iPhone IOS4

I am currently developing an HTML-based application with a JSON wrapper. Ever since the recent 4.0.2 update, the video playback on iPhones has been experiencing some issues. Despite having all the necessary code in HTML to play the video files, post-update ...

Adaptable triple-column design

After completing the layout of my website, everything seems to be functioning well. However, I would like to ensure that I haven't overcomplicated it or used poor techniques. The structure involves a main DIV with a nested table DIV, inside of which ...

Displaying XML data in an HTML table

Encountered a challenge while fetching data from an external XML document using JS. Following the w3schools tutorial for AJAX XML, but faced an issue I couldn't resolve. The XML structure is as follows: <root> <document-id> <author ...

Distinguish between individuals who are sharing login credentials

At the moment, I am distinguishing users by using $_SESSION[id]. However, I have noticed that some users are sharing their login information on multiple devices at the same time. This could potentially create issues in the system. If there is a method to ...

Masonry style attempted for posts but did not produce desired outcome

I've been experimenting with different methods to achieve a masonry style layout for my posts. So far, using float:left seems to work almost perfectly, but occasionally there are gaps between the posts. I'm on the lookout for a solid solution to ...

Do not insert a MUI divider after the final item in the menu

Is there a way to remove the divider after the last category when using MUI components and adding a divider after each category? https://i.sstatic.net/Gx0Zb.png This is my code with the divider right at the bottom before the closing tag. export const ...

Unable to reset iframe style height in IE8 using JavaScript

I am encountering an issue with resetting the height of an iframe using JavaScript. Here is the code snippet I am working with: var urlpxExt = document.getElementById('urlPx'); urlpxExt.style.height = "200px"; While this approach works well in m ...

Styling the Web with CSS in Django 2.0

I have a teammate who wrote some HTML code with CSS/Bootstrap. Now I am trying to render it in Django, but it's not displaying properly. It works fine as an HTML file, though. <meta charset="utf-8"> <meta name="viewport" content="width=devic ...