html2print.scss 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /**
  2. * Computation
  3. */
  4. /* EXTRA SPACE AROUND THE PAGE: BLEED + CROP */
  5. // TODO: find a more appropriate name
  6. $crop: $crop-size + $bleed;
  7. /* GEOMETRY OF THE PAPER SHEET */
  8. $paper-width: $page-width + ( $crop * 2 );
  9. $paper-height: $page-height + ( $crop * 2 );
  10. /* SIZE OF SPREAD */
  11. $spread: $page-width * 2;
  12. /**
  13. * DEFINITION OF THE PAPER SHEET
  14. */
  15. @page {
  16. size: $paper-width ($paper-height + 1);
  17. margin: 0;
  18. }
  19. /**
  20. * CANVAS
  21. */
  22. @media all {
  23. body {
  24. margin: 0;
  25. }
  26. .paper {
  27. width: $paper-width;
  28. height: $paper-height;
  29. box-sizing: border-box;
  30. counter-increment: page-counter;
  31. // To make sure that one paper sheet is not splitted into different pages in the PDF
  32. page-break-inside: avoid;
  33. page-break-after: always;
  34. overflow: hidden;
  35. /* Crop marks */
  36. padding: $crop;
  37. position: relative;
  38. .crops {
  39. width: $paper-width;
  40. height: $paper-height;
  41. position: absolute;
  42. top: 0;
  43. left: 0;
  44. div {
  45. border-style: solid;
  46. border-color: black;
  47. border-width: 0;
  48. width: $crop;
  49. height: $crop;
  50. position: absolute;
  51. box-sizing: border-box;
  52. span {
  53. width: $bleed;
  54. height: $bleed;
  55. background-color: white;
  56. position: absolute;
  57. }
  58. }
  59. .crop-top-left {
  60. border-right-width: 1px;
  61. border-bottom-width: 1px;
  62. top: 0;
  63. left: 0;
  64. span { right: -1px; bottom: -1px;}
  65. }
  66. .crop-top-right {
  67. border-left-width: 1px;
  68. border-bottom-width: 1px;
  69. top: 0;
  70. right: 0;
  71. span { left: -1px; bottom: -1px;}
  72. }
  73. .crop-bottom-right {
  74. border-left-width: 1px;
  75. border-top-width: 1px;
  76. right: 0;
  77. bottom: 0;
  78. span { left: -1px; top: -1px;}
  79. }
  80. .crop-bottom-left {
  81. border-right-width: 1px;
  82. border-top-width: 1px;
  83. left: 0;
  84. bottom: 0;
  85. span { right: -1px; top: -1px;}
  86. }
  87. }
  88. }
  89. .page {
  90. width: $page-width;
  91. height: $page-height;
  92. position: relative;
  93. box-sizing: border-box;
  94. overflow: hidden;
  95. }
  96. // TODO: changer le format du papier en spread pour pouvoir imprimer en planche
  97. .spread {
  98. .paper {
  99. float: left;
  100. }
  101. .paper:nth-child(odd) {
  102. margin-left: -$crop;
  103. }
  104. .paper:nth-child(even) {
  105. margin-right: -$crop;
  106. }
  107. .paper:first-child {
  108. margin-left: $page-width;
  109. }
  110. }
  111. }
  112. @media print {
  113. html {
  114. width: $paper-width;
  115. }
  116. body {
  117. /* Allows printing of background colors */
  118. background-color: white;
  119. -webkit-print-color-adjust: exact;
  120. print-color-adjust: exact;
  121. /* Activate opentype features and kernings */
  122. -webkit-font-feature-settings: "liga", "dlig", "clig", "kern";
  123. text-rendering: optimizeLegibility;
  124. }
  125. }
  126. /**
  127. * Helpers
  128. */
  129. .region-break {
  130. /* Apply this class to an element to put it on a new region.
  131. * Hint:
  132. * You can also use an empty <div class="page-break"></div>
  133. * if you want to put manual page breaks without attaching it to an HTML element
  134. */
  135. -webkit-region-break-before: always;
  136. break-before: always;
  137. }