Get the Best Width for CSS3 Printing

After running my code to window print the table (report), the output is displayed below:

https://i.sstatic.net/chZ2b.png

This is the code I used:

CSS

  @media print {
  body * {
    visibility: hidden;
  }
  #reportArea, #reportArea * {
    visibility: visible;
  }
  #reportArea {
    position: absolute;
    left: 0;
    top: 0;
  }
}

HTML (blade):

<button type="submit" class="btn btn-success hidden-print" onclick="window.print();">
<i class="fa fa-print"></i> Print
</button>

<div id="reportArea">
      <div class="box-body table-responsive no-padding">
        <table class="table table-striped table-bordered">
          <thead>
            <tr>
              <th>Room #</th>
              <th>Invoice #</th>
              <th>Client Name</th>
              <th>Booked At</th>
              <th>Reservation From</th>
              <th>Reservation To</th>
              <th>Amount</th>
          </thead>
          </tr>
          <tbody>
            @foreach($reservations as $res)
            <tr>
              <td>{{ $res -> room -> room_number }}</td>
              <td></td>
              <td>{{ $res -> client -> name }}</td>
              <td>{{ date('F d, Y', strtotime($res -> created_at )) }}</td>
              <td>{{ date('F d, Y', strtotime($res -> reservation_from)) }}</td>
              <td>{{ date('F d, Y', strtotime($res -> reservation_to)) }}</td>
              <td>{{ $res -> charge -> sum('price') }}</td>
            </tr>
            @endforeach
            <tr>
              <td colspan="2"><strong>Total:</strong></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td><strong>{{ $total }}</strong></td>
            </tr>
          </tbody>
        </table>
      </div>
      </div>

If you have any suggestions on how I can optimize paper usage, especially considering the large empty spaces on the left and right sides, or if there's a more efficient way to accomplish this task, please let me know. Thank you.

Answer №1

To set page margins, use the following code:

@page {
  margin: 0;
}

Answer №2

To ensure the width is at full stretch, set it to 100%

#reportsection
{
    width:100%;
}

An alternative approach could be:

#reportsection
{
    left:0;
    right:0;
    padding:0;
}

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

What is the best way to ensure that all rows in flexbox have the same number and dimensions as the first row?

My objective with flexbox was to evenly distribute the text across the width of the page. When I say 'evenly distributed', I mean: If there are 3 sections, the center of the text in each section should be at fifths of the webpage width. This is ...

How can a Vue.js toggle button dynamically change based on the combined state of two checkboxes?

My current project involves implementing a toggle feature that allows users to enable a day and then select between AM or PM using checkboxes. One issue I'm facing is how to de-toggle the button if a user unchecks both AM and PM options. Check out t ...

Leverage the source code of Angular 2 in your project for seamless integration

Currently in the process of setting up Angular with npm: npm install @angular... Encountering an issue where the TypeScript source files are not included. I would like to have access to debug the code using the TypeScript source files (with source maps). ...

Issue with THREE.js: Object picking does not display the parent object name when an object is loaded using OBJMTLLoader

I successfully loaded an OBJ file along with MTL file textures using OBJMTLLoader. The code I used was borrowed from . The primary object, a man in a business suit with hair, hands, and shoes, is displayed correctly with all the textures applied, such as ...

What is the best way to make a div that maintains its size even when the content inside is modified?

My goal is to develop a media feed that includes various types of content such as text, images, and videos. To ensure user safety, I want to conceal any explicit posts with a warning that requires the user to click in order to view the content. Although I ...

html safeguarding user accounts

function Authenticate() { loggedIn = false; username = ""; password = ""; username = prompt("Please enter your username:", ""); username = username.toLowerCase(); password = prompt("Please enter your password:", ""); password = ...

What is the best way to implement a timer or interval system in React and Next.js that continues running even when the tab is not in focus or the browser is in

I am attempting to create a stopwatch feature using next js. However, I have encountered an unusual issue where the stopwatch does not function correctly when the tab is not focused or when the system goes to sleep or becomes inactive. It appears that the ...

How to address additional attributes received from the server in Next.JS

Encountering an error while trying to render a canvas with specified height and width within a child component in a NextJs app. The issue arises when attempting to integrate this mouse effect into my NextJS application. Everything functions correctly until ...

Utilizing Cordova and jQuery-mobile to launch links in a separate device browser

My app has numerous links, all of which I have added rel='external' target='_blank' to. While this works perfectly in the Ripple emulator and regular desktop browsers, it doesn't function correctly on my Android device running JB 4 ...

Decoding the Mystery: What Do the + and # Symbols Mean in Angular 4 Routes?

Check out the repository at https://github.com/AngularClass/angular-starter https://i.sstatic.net/ITi80.png I noticed the use of + and # for referencing within loadChildren and naming conventions in the folder... After consulting the Angular documentati ...

Specialized function to identify modifications in data attribute value

I have a container with a form inside, featuring a custom data attribute named data-av Here is how I am adding the container dynamically: > $("#desti_div").append("<div class='tmar"+count+"'><div > class='form-group col-md-6 ...

Updating the MLM binary tree system

In my JavaScript nested object, the IDs of objects increase in depth. By using JavaScript support, I added an object inside ID - 2 with a children array of 3. What I need is to update (increment) the IDs of all siblings in the tree. This code snippet shoul ...

Create a 3D vertical flip effect for images using CSS

Learning About HTML <div class="container"> <div class="wrapper"> <div class="im-fix"><img src="foo.jpg"></div> <div class="img-closed"><img src="foo-close.jpg"></div> <div class="img- ...

The floating left div displays oddly when it wraps onto the next line

I currently have a variable number of floating divs, ranging from 1 to 10. When I display either 1-5 or all 10, they appear correctly: item1 item2 item3 item4 item5 item6 item7 item8 item9 item10 However, when I try to display around 7 of them, things s ...

When a Vue.js datepicker is set as required, it can be submitted even if

When using the vuejs-datepicker, setting the html required attribute on input fields may not work as expected. This can lead to the form being submitted without an input value. <form> <datepicker placeholder="Select Date" required></datep ...

Access a webpage on a raspberry pi 3 using a smartphone

I am attempting to view a webpage that utilizes HTML/CSS/JavaScript on my Raspberry Pi. However, my Raspberry Pi will not have internet access but I still want to be able to view this webpage from my smartphone. Due to the fact that my Pi is offline and I ...

Refresh stock value in anychart without having to re-render the entire chart

I am currently experimenting with the Anychart stock candlestick chart and I must say, it is quite impressive. However, I have encountered an issue while trying to update the chart using a setInterval function. The problem is that it re-plots the entire ch ...

How can I deactivate Bootstrap specifically within a certain block of content?

Is there a way to deactivate Bootstrap within a specific section? I want the styles from Bootstrap's CSS file to be overridden inside this div. ...

Use a JSON file to dynamically define the file path for static assets in the index.html file of a React application

I am working on a solution to dynamically modify the file paths of static files (js & css) in the index.html file within my create-react-app. My goal is to have these paths directed to different sub-directories based on settings specified in a settings.jso ...

concealing the upper header while scrolling and shifting the primary header upwards

Is there a way to use CSS to move the main header navigation, including the logo and links, on my website up when scrolling down in order to hide the top black bar header that contains contact information? The website in question is atm.truenorthmediasol ...