How to fit the page into landscape while print

Viewed 66

I need to print a page, while giving to print it is splitting to two pages. The page is splitting after the second table, is there any way to fit it to one page.

enter image description here

I am providing the code below

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>View JTC</title>

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>

<style type="text/css" media="print">
@media print {
    html, body {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
    }
    
    table {
        page-break-inside: avoid;
    }
    @page {
        size: A4 landscape;
    }
}
</style>

</head>
<body>
    <section class="container-fluid">

        <table class="table table-sm table-bordered table-condensed">

            <tr>
                <th style="width: 30%; vertical-align: middle; text-align: center;">logo</th>
                <th colspan="2" style="text-align: center; width: 70%">company</th>
            </tr>

            <tr>
                <th rowspan="2" style="text-align: center; vertical-align: middle;">Job
                    Travel Card</th>
                <th style="width: 10%;">JTC No:</th>
                <th></th>
            </tr>

            <tr>
                <th>Date</th>
                <th></th>
            </tr>
        </table>
        <table class="table table-sm  table-bordered table-condensed">

            <tr>
                <td style="width: 10%; text-align: left;">Project Number</td>
                <td style="width: 15%; text-align: left;" colspan="2"></td>
                <td style="width: 10%; text-align: left;">Unit No. / Tag No.</td>
                <td style="width: 15%; text-align: left;" colspan="4"></td>
            </tr>

            <tr>
                <td>Area Number</td>
                <td colspan="2"></td>
                <td>Material Class</td>
                <td colspan="4"></td>
            </tr>

            <tr>
                <td style="width: 15%; text-align: left;">Drawing No: / ISO
                    Number</td>
                <td style="width: 15%; text-align: left;"></td>
                <td style="width: 15%; text-align: left;">JC No:</td>
                <td style="width: 15%; text-align: left;"></td>

                <td style="width: 10%; text-align: left;">Sheet No</td>
                <td style="width: 15%; text-align: left;"></td>

                <td style="width: 10%; text-align: left;">Rev. No.</td>
                <td style="width: 15%; text-align: left;"></td>

            </tr>

            <tr>
                <td style="width: 15%; text-align: left;">Item Description</td>
                <td style="width: 15%; text-align: left;" colspan="2"></td>
                <td style="width: 15%; text-align: left;">ITP Stage Nos.</td>
                <td style="width: 15%; text-align: left;" colspan="4"></td>
            </tr>
        </table>
        <!-- Fitup data table-sm  -->
        <table class="table  table-bordered table-condensed">

            <tr>
                <th rowspan="12" style="text-align: center; vertical-align: middle;">
                    <span class="verticaltext"> Fabrication Assembly Fit-Up </span>
                </th>
                <th style="text-align: center; vertical-align: middle;" rowspan="2">Weld/joint
                    No</th>
                <th style="text-align: center; vertical-align: middle;" rowspan="2">Item/Position
                    No.</th>
                <th colspan="2">Material Spec Grade</th>
                <th style="text-align: center; vertical-align: middle;" rowspan="2">Size</th>
                <th style="text-align: center; vertical-align: middle;" rowspan="2">Thickness</th>
                <th colspan="2">Heat/Plate/TestNo</th>
                <th style="text-align: center; vertical-align: middle;" rowspan="2">Welder
                    No. for tracking</th>
                <th colspan="2">Fitup Result</th>
                <th style="text-align: center; vertical-align: middle;" rowspan="2">Date</th>
                <th style="text-align: center; vertical-align: middle;" rowspan="2">Sign</th>
            </tr>
            <tr>

                <th>Material 1</th>
                <th>Material 2</th>

                <th>Material 1</th>
                <th>Material 2</th>

                <th>Accept</th>
                <th>Reject</th>

            </tr>
    
                <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
        
                    <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                        
            <tr>
                <td colspan="4">Name & Signature of fabrication foreman</td>
                <td colspan="2">Released to</td>

                <td colspan="2"><input type="checkbox"> QC/NDE/DIM.</td>
                <td colspan="2"><input type="checkbox"> Welding</td>

                <td colspan="4"><input type="checkbox">
                    Fabrication/Assembly</td>
            </tr>

            <tr>
                <td colspan="7">Date</td>
                <td colspan="7">Date</td>
            </tr>
        </table>
        <!-- welding data -->
        <table class="table table-bordered table-condensed">
            <tr>
                <th rowspan="13" style="text-align: center; vertical-align: middle;">
                    <span class="verticaltext"> Welding Details </span>
                </th>

                <th style="text-align: center; vertical-align: middle;" rowspan="3">Joint
                    No</th>
                <th style="text-align: center; vertical-align: middle;" rowspan="3">WPS
                    No.</th>
                <th colspan="3" class="text-center">Welding Process</th>
                <th colspan="3" class="text-center">Welder/Operation No.</th>
                <th colspan="2" rowspan="2" class="text-center">Visual
                    Inspection</th>
                <th style="text-align: center; vertical-align: middle;" rowspan="3">Date</th>
                <th style="text-align: center; vertical-align: middle;" rowspan="3">Sign</th>
            </tr>
            <tr>
                <th colspan="3" class="text-center">Passes</th>
                <th colspan="3" class="text-center">Passes</th>
            </tr>
            <tr>
                <th class="text-center">Root/Hot</th>
                <th class="text-center">Fill</th>
                <th class="text-center">Cap</th>

                <th class="text-center">Root/Hot</th>
                <th class="text-center">Fill</th>
                <th class="text-center">Cap</th>

                <th class="text-center">Accept</th>
                <th class="text-center">Reject</th>
            </tr>
                <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>

            <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
            <tr>
                <td colspan="4">Name & Signature of fabrication foreman</td>
                <td colspan="3">Released to</td>

                <td colspan="2"><input type="checkbox"> QC/NDE/DIM.</td>
                <td colspan="1"><input type="checkbox"> Welding</td>

                <td colspan="4"><input type="checkbox">
                    Fabrication/Assembly</td>
            </tr>
            <tr>
                <td colspan="14">Name & Signature of QC Personel</td>
            </tr>
            <tr>
                <td colspan="7">Date</td>
                <td colspan="7">Date</td>
            </tr>
        </table>
    </section>
    </div>
</body>
</html>

There are 10 rows in each table, due to stack overflow limitations I short the code. Can any one help me with this Thank you in advance.

1 Answers

I did try with 10 rows in the two tables and this configuration seems to have worked out for me.

<style type="text/css" media="print">
    @media print {
        html, body {
            height: 100%;
            width: 100%;
        }
        
        table:nth-of-type(2) {
            margin-top:-90px;
            margin-bottom: 0;
        }
        @page {
            size: A4 landscape;
            margin: 0;
        }
    }
</style>

table:nth-of-type(2) is used to specifically work on the 2nd table, in your case the Fabrication Assembly Fit-Up Table. Hope this helped.

Related