save method
Generates the PDF document as a memory file.
Runs in a background isolate when supported (e.g., on Dart VM), or on the main isolate when isolate support is unavailable (e.g., on the web).
If enableEventLoopBalancing is true, the method yields periodically
during processing to keep the event loop responsive. This helps reduce
blocking when the operation runs on the main isolate.
Returns a Uint8List containing the document data.
Implementation
Future<Uint8List> save({bool enableEventLoopBalancing = false}) async {
return pdfCompute(() async {
final os = PdfStream();
if (prev != null) {
os.putBytes(prev!.bytes);
}
await _write(os, enableEventLoopBalancing: enableEventLoopBalancing);
return os.output();
});
}