reportCssPrint function

String reportCssPrint(
  1. String pageSize
)

CSS for printing a report on pageSize paper.

Implementation

String reportCssPrint(String pageSize) => '''
/* aa ### flutter extension
   Print version: same appearance as the screen preview, with the
   "reader" decoration stripped out — the gray backdrop, shadow, and
   inter-page gaps shouldn't be printed on paper; the sheet should lie
   flat and use all of the printable area. */

html, body { margin: 0; padding: 0; }

body {
  font-family: "Microsoft JhengHei", "Noto Sans TC", -apple-system, "Segoe UI", sans-serif;
  font-size: 13.3px;
  color: #2C2C2A;
  background: #F5F4F0;
  padding: 20px 0;
}

body > table {
  background: #ffffff;
  margin: 0 auto 20px auto;
  padding: 8px 16px 10px 16px;
  box-shadow: 0 1px 5px rgba(0,0,0,.16);
  border-collapse: separate;
}
body > table table { width: 100%; border-collapse: collapse; }
body > table > tbody > tr > td { padding: 0; border: 0; }

/* @@@ 2026-08-10 added: the same visual-stitching rule as reportCssScreen --
   some WML prints an extra trailing block after the paper container's
   (outer </table>'s) closing tag (e.g. a page-number row); this makes that
   block share the paper's white background and shadow so the two seams
   together. Width follows the 740px WML commonly uses (body>table itself
   has no width set here -- left alone; only the trailing block is handled). */
body > table:has(+ p:last-child) {
  margin-bottom: 0;
  box-shadow: 0 -1px 5px rgba(0,0,0,.16);
}
body > table + p:last-child {
  width: 740px;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0 auto 20px auto;
  padding: 4px 16px 10px 16px;
  background: #ffffff;
  box-shadow: 0 1px 5px rgba(0,0,0,.16);
}

big { font-size: 1.35em; font-weight: 700; letter-spacing: 1px; color: #1a1a18;
      display: block; line-height: 1.4; }

/* Header block (the first nested table): collapse <p>/<td> spacing,
   otherwise it ends up far too tall */
p { margin: 0; padding: 0; }
body > table td > table:first-of-type td { /* @@@ allow an extra nesting level in case the WML brings its own centering frame */
  border-bottom: 0; padding: 1px 4px; font-size: 12.3px; color: #5F5E5A;
}

th {
  background: #D0CFC9; color: #2C2C2A; font-weight: 600; font-size: 13.3px;
  padding: 4px; text-align: center; white-space: normal; word-break: break-word;
}
tr.row th { background: #D0CFC9; color: #2C2C2A; }
tr.row    { background: transparent; }

/* @@@ Data tables use a fixed layout so <th width>/column widths are
   strictly honored (auto layout would not shrink below content width).
   @@@ 2026-08-10: margin-top 6px -- p{margin:0} keeps the header block
   compact, but that also pins the header's last line (often a ruler line /
   customer info) right up against the detail table's first row; this gives
   the detail table a little breathing room on its own, without loosening
   the header block's compactness. */
body > table td > table:not(:first-of-type) { table-layout: fixed; width: 100%; margin-top: 6px; }

td { padding: 4px; font-size: 13.3px; font-weight: 500; color: #2C2C2A; border-bottom: 1px solid #E8E7E1; vertical-align: top; }

tr.grp td { background: #EDEAE3; font-weight: 700; color: #185FA5; padding: 5px 5px; }

tr.sub td { background: #FAFAF8; font-size: 12.3px; color: #5F5E5A; padding: 3px 5px; }
tr.sub td:first-child { padding-left: 22px; }

.row1 { background: ${WapColors.hexTrRow1}; }
.row2 { background: ${WapColors.hexTrRow2}; }

/* @@@ 2026-08-10 added: the same fallback as reportCssScreen -- reports
   without an explicit class="row1"/"row2" still get zebra striping,
   auto-detected via :nth-child. */
body > table td > table:not(:first-of-type) tr:not(.row):not(.row1):not(.row2):not(.grp):not(.sub):not([height]):nth-child(even) td {
  background: ${WapColors.hexTrRow2};
}

/* ── Print: strip the reader chrome, let the sheet lie flat ── */
@media print {
  @page { size: $pageSize; margin: 10mm; }   /* smaller margins → maximize printable area */
  body {
    background: #ffffff;
    padding: 0;
    -webkit-print-color-adjust: exact;       /* keep header/group-row background colors */
    print-color-adjust: exact;
  }
  body > table {
    box-shadow: none;
    margin: 0;
    padding: 0;
    width: 100% !important;
  }
  tr, td, th { page-break-inside: avoid; }   /* don't let a row split across two pages */
}
/* zz ### flutter extension */
''';