drawUnderlay method

void drawUnderlay(
  1. void build(
    1. PdfGraphics canvas
    )
)

Draws under the original content.

Useful for a watermark: the page content stays legible on top. Successive calls stack in the order they were made, the first one furthest back.

Implementation

void drawUnderlay(void Function(PdfGraphics canvas) build) {
  _ensureWrap();
  final canvas = page.getGraphics();
  final stream = page.contents.last as PdfObjectStream;
  canvas.saveContext();
  build(canvas);
  canvas.restoreContext();
  _insertContent(stream, _underlayCount);
  _underlayCount++;
  page.altered = true;
}