html2print.less 3.71 KB
Newer Older
alexandre's avatar
alexandre committed
1 2 3 4 5
/**
 * Computation
 */


svilayphiou's avatar
svilayphiou committed
6 7 8
/* EXTRA SPACE AROUND THE PAGE: BLEED + CROP */
// TODO: find a more appropriate name
@crop: @crop-size + @bleed; 
alexandre's avatar
alexandre committed
9

svilayphiou's avatar
svilayphiou committed
10
/* GEOMETRY OF THE PAPER SHEET */
alexandre's avatar
alexandre committed
11 12 13
@paper-width: @page-width + ( @crop * 2 );
@paper-height: @page-height + ( @crop * 2 );

svilayphiou's avatar
svilayphiou committed
14 15 16 17
/* SIZE OF SPREAD */
@spread: @page-width * 2;


alexandre's avatar
alexandre committed
18 19

/**
svilayphiou's avatar
svilayphiou committed
20
 * DEFINITION OF THE PAPER SHEET
alexandre's avatar
alexandre committed
21 22
 */
@page {
23
    size: @paper-width (@paper-height + 1); 
alexandre's avatar
alexandre committed
24 25 26 27 28
    margin: 0;
}


/**
svilayphiou's avatar
svilayphiou committed
29
 * CANVAS
alexandre's avatar
alexandre committed
30 31 32
 */

@media all {
33 34
    body {
        margin: 0;
alexandre's avatar
alexandre committed
35 36
    }
    .paper {
37 38 39
        width: @paper-width; 
        height: @paper-height;
        box-sizing: border-box;
alexandre's avatar
alexandre committed
40

alexandre's avatar
alexandre committed
41 42
        counter-increment: page-counter;

43
        // To make sure that one paper sheet is not splitted into different pages in the PDF
alexandre's avatar
alexandre committed
44 45 46 47
        page-break-inside: avoid;
        page-break-after: always;
        overflow: hidden;

48
        /* Crop marks */
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
        padding: @crop;
        position: relative;
        .crops {
            width: @paper-width; 
            height: @paper-height;
            position: absolute;
            top: 0;
            left: 0;

            div {
                border-style: solid;
                border-color: black;
                border-width: 0;
                width: @crop;
                height: @crop;
                position: absolute;
                box-sizing: border-box;

                span {
                    width: @bleed;
                    height: @bleed;
                    background-color: white;
                    position: absolute;
                }
            }
            .crop-top-left {
                border-right-width: 1px;
                border-bottom-width: 1px;
                top: 0;
                left: 0;

                span { right: -1px; bottom: -1px;}
            }
            .crop-top-right {
                border-left-width: 1px;
                border-bottom-width: 1px;
                top: 0;
                right: 0;

                span { left: -1px; bottom: -1px;}
            }
            .crop-bottom-right {
                border-left-width: 1px;
                border-top-width: 1px;
                right: 0;
                bottom: 0;

                span { left: -1px; top: -1px;}
            }
            .crop-bottom-left {
                border-right-width: 1px;
                border-top-width: 1px;
                left: 0;
                bottom: 0;

                span { right: -1px; top: -1px;}
            }
        }
alexandre's avatar
alexandre committed
107 108
    }
    .page {
alexandre's avatar
alexandre committed
109 110
        width: @page-width;
        height: @page-height;
alexandre's avatar
alexandre committed
111
        position: relative;
112 113
        box-sizing: border-box;
        overflow: hidden;
alexandre's avatar
alexandre committed
114 115 116
    }

    // TODO: changer le format du papier en spread pour pouvoir imprimer en planche
svilayphiou's avatar
svilayphiou committed
117 118 119 120 121 122 123 124 125 126 127 128 129
    .spread {
        .paper {
            float: left;
        }
        .paper:nth-child(odd) {
            margin-left: -@crop;
        }
        .paper:nth-child(even) {
            margin-right: -@crop;
        }
        .paper:first-child {
            margin-left: @page-width;
        }
alexandre's avatar
alexandre committed
130 131 132 133 134 135 136 137 138
    }
}

@media print {
    html {
        width: @paper-width;
    }
    body {
        /* Allows printing of background colors */
139
        background-color: white;
alexandre's avatar
alexandre committed
140 141
        -webkit-print-color-adjust: exact;
                print-color-adjust: exact;
svilayphiou's avatar
svilayphiou committed
142 143 144
        /* Activate opentype features and kernings */
        -webkit-font-feature-settings: "liga", "dlig", "clig", "kern";
        text-rendering: optimizeLegibility;
alexandre's avatar
alexandre committed
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
    }
}



/**
 * Helpers
 */

.region-break {
    /* Apply this class to an element to put it on a new region.
     * Hint: 
     * You can also use an empty <div class="page-break"></div> 
     * if you want to put manual page breaks without attaching it to an HTML element
     */
    -webkit-region-break-before: always;
161
                   break-before: always;
alexandre's avatar
alexandre committed
162
}