Guest User

Untitled

a guest
Nov 17th, 2021
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 3.05 KB | None | 0 0
  1. /* Test */
  2. :root {
  3.     --page-short-edge: 210mm;
  4.     --page-long-edge: 297mm;
  5.     /* For Firefox this needs to be 290mm */
  6.  
  7.     --page-margin: 15mm;
  8.  
  9.     --page-width-portrait: var(--page-short-edge);
  10.     --page-height-portrait: var(--page-long-edge);
  11.  
  12.     --page-usablewidth-portrait: calc(var(--page-short-edge) - (var(--page-margin) * 2));
  13.     --page-usableheight-portrait: calc(var(--page-long-edge) - (var(--page-margin) * 2));
  14.  
  15.     --page-width-landscape: var(--page-long-edge);
  16.     --page-height-landscape: var(--page-short-edge);
  17.  
  18.     --page-usablewidth-landscape: calc(var(--page-long-edge) - (var(--page-margin) * 2));
  19.     --page-usableheight-landscape: calc(var(--page-short-edge) - (var(--page-margin) * 2));
  20.  
  21.     /* The fuck */
  22.     --page-landscape-left: calc(var(--page-margin)*2*(-1.449));
  23.     --page-landscape-top: calc(var(--page-margin)*2*(1.444));
  24. }
  25.  
  26. @page {
  27.     size: A4 portrait;
  28.     margin: 15mm; /* var() doesn't work correctly here?!? */
  29. }
  30.  
  31. @media print {
  32.     html {
  33.         padding: 0;
  34.         margin: 0;
  35.     }
  36.     body {
  37.         padding: 0;
  38.         margin: 0;
  39.     }
  40.     /* Force-hide unnecessary stuff for proper layout */
  41.     div.globalProgressBar, div.rootTopBar, div.rootBottomBar {
  42.         display: none;
  43.     }
  44.     /* Force-disable flex boxes for proper layout */
  45.     div#root, div.rootContentArea {
  46.         display: block !important;
  47.     }
  48.     div.tableContainer, div.chartContainer, div.datagridContainer {
  49.         display: block !important;
  50.         padding: 0;
  51.         margin: 0;
  52.     }
  53.     /* Fixed page size */
  54.     div.printPortraitSinglePage {
  55.         width: var(--page-usablewidth-portrait);
  56.         height: var(--page-usableheight-portrait);
  57.         overflow-x: visible;
  58.         break-before: page;
  59.    
  60.         padding: 0;
  61.         margin: 0;
  62.     }
  63.     /* Enforce page width*/
  64.     div.printPortraitRunningPage {
  65.         width: var(--page-usablewidth-portrait);
  66.         overflow-x: visible;
  67.         break-before: auto;
  68.    
  69.         padding: 0;
  70.         margin: 0;
  71.     }
  72.     /* Fixed page size */
  73.     div.printLandscapeSinglePage {
  74.         width: var(--page-usablewidth-landscape) !important;
  75.         height: var(--page-usableheight-landscape)  !important;
  76.         overflow-x: visible;
  77.         overflow-y: visible;
  78.         break-before: avoid;
  79.         break-after: page;
  80.         transform: rotate(90deg);
  81.         position: relative;
  82.  
  83.         left: var(--page-landscape-left) !important;
  84.         top: var(--page-landscape-top) !important;
  85.  
  86.         padding: 0;
  87.         margin: 0;
  88.     }
  89.     /* Enforce page size */
  90.     div.printLandscapeRunningPage {
  91.         width: var(--page-usablewidth-landscape) !important;
  92.         overflow-x: visible;
  93.         overflow-y: visible;
  94.         break-before: page;
  95.         transform: rotate(90deg);
  96.         position: relative;
  97.  
  98.         left: var(--page-landscape-left) !important;
  99.         top: var(--page-landscape-top) !important;
  100.  
  101.        padding: 0;
  102.         margin: 0;
  103.     }
  104.     /* */
  105.     div.printContain {
  106.         break-inside: avoid;
  107.     }
  108. }
  109.  
Add Comment
Please, Sign In to add comment