customPaperSizeInches function

(double, double)? customPaperSizeInches(
  1. String paper
)

@@@ 2026-08-10 added: custom paper size, format "WIDTHxHEIGHT" (inches), e.g. the 8.5x5.5 pre-printed continuous-form paper common in Taiwan. Shares the same detection logic as named sizes (letter/A4...) -- all three call sites (screen width, CSS @page, PdfPageFormat) call this, so they never disagree. Returns null when it isn't a custom format, leaving normalizePaper to handle the named-size path.

Implementation

(double, double)? customPaperSizeInches(String paper) {
  final p = _expandAttr(paper).trim().toLowerCase();
  final m = RegExp(r'^(\d+(?:\.\d+)?)\s*x\s*(\d+(?:\.\d+)?)$').firstMatch(p);
  if (m == null) return null;
  final w = double.tryParse(m.group(1)!);
  final h = double.tryParse(m.group(2)!);
  if (w == null || h == null || w <= 0 || h <= 0) return null;
  return (w, h);
}