Search code examples
htmlangular-ui-bootstrappre

HTML pre tag printing extra line if bootstrap is used


I am having difficulty when printing pre tag where the number of records printing is more than 53 using bootstrap and I always get empty page in print preview. However, if the record is less than 52, then I can do printing successfully. Please see my code below.

<html ng-app="appMain">
<head>
    <script src="lib/angular.js"></script>
    <script src="lib/moment.js"></script>
    <script src="js/app.js"></script>
    <link rel="stylesheet" href="css/bootstrap.css?v3.3">
</head>
<body>
    <div ng-controller='ctrlMain'>            
        <table>
            <tr>                
                <td><button ng-click="fnPrintXMLData()"> Print </button></td>
            </tr>
        <table>
        <label>test label</label>
        <div class="clearfix">&nbsp;</div>                           
        <span ng-show="message.id"><h4>Detail Message</h4></span>
        <div class="clearfix">&nbsp;</div>
        <pre class="printDisplayBox" style="white-space: pre-wrap; word-break: normal;">
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        22
        23
        24
        25
        26
        27
        28
        29
        30
        31
        32
        33
        34
        35
        36
        37
        38
        39
        40
        41
        42
        43
        44
        45
        46
        47
        48
        49
        50
        51
        52
        53
        54
        55
        </pre>
    </div>
</body>

and in controller

appMain.controller('ctrlMain', ['$scope', function($scope) {
$scope.fnPrintXMLData = function() {
    window.print();
};}]);

And the result when I print is this: Printing with bootstrap If I comment out " " or the record count is less than 52, then the result is ok which is Printing without bootstrap

Can Anyone please help me on this? Thanks a lot.


Solution

  • your html:

    <pre class="printDisplayBox" style="white-space: pre-wrap;word-break: normal;width: 100%;display: -webkit-inline-box !important;">