paint method

  1. @protected
void paint(
  1. Widget child,
  2. Context context
)

Implementation

@protected
void paint(Widget child, Context context) {
  final _margin = resolvedMargin!;
  final box = PdfRect(
    _margin.left,
    _margin.bottom,
    pageFormat.width - _margin.horizontal,
    pageFormat.height - _margin.vertical,
  );
  if (pageTheme.clip) {
    context.canvas
      ..saveContext()
      ..drawRect(box.x, box.y, box.width, box.height)
      ..clipPath();
  }

  if (pageTheme.textDirection == TextDirection.rtl) {
    child.box = PdfRect(
      ((mustRotate ? box.height : box.width) - child.box!.width) +
          child.box!.x,
      child.box!.y,
      child.box!.width,
      child.box!.height,
    );
  }

  if (mustRotate) {
    final _margin = resolvedMargin!;
    context.canvas
      ..saveContext()
      ..setTransform(Matrix4.identity()
        ..rotateZ(-math.pi / 2)
        ..translate(
          -pageFormat.height - _margin.left + _margin.top,
          -pageFormat.height + pageFormat.width + _margin.top - _margin.right,
        ));
    child.paint(context);
    context.canvas.restoreContext();
  } else {
    child.paint(context);
  }

  if (pageTheme.clip) {
    context.canvas.restoreContext();
  }
}