save method

Future<Uint8List> save({
  1. bool enableEventLoopBalancing = false,
})

Generates the PDF document as a memory file.

If enableEventLoopBalancing is true, the method yields periodically during processing to keep the event loop responsive. This can help avoid blocking during the processing of large documents.

Returns a Uint8List containing the document data.

Implementation

Future<Uint8List> save({bool enableEventLoopBalancing = false}) async {
  if (!_paint) {
    final balancer = enableEventLoopBalancing ? EventLoopBalancer() : null;
    balancer?.start();

    for (final page in _pages) {
      await balancer?.yieldIfNeeded();
      page.postProcess(this);
    }

    balancer?.stop();
    _paint = true;
  }

  return await document.save(
    enableEventLoopBalancing: enableEventLoopBalancing,
  );
}