renderPage method
Renders the page into a canvas and return image's byte information.
Implementation
Future<Uint8List> renderPage(PdfJsPage page, PdfJsViewport viewport,
int fullWidth, int fullHeight, String documentID) async {
final html.CanvasElement htmlCanvas =
js.context['document'].createElement('canvas');
final Object? context = htmlCanvas.getContext('2d');
final _viewport = page.getViewport(_settings);
viewport =
page.getViewport(Settings()..scale = (fullWidth / _viewport.width));
htmlCanvas
..width = fullWidth
..height = fullHeight;
final renderSettings = Settings()
..canvasContext = (context as html.CanvasRenderingContext2D)
..viewport = viewport
..annotationMode = 0;
await promiseToFuture<void>(page.render(renderSettings).promise);
return htmlCanvas.context2D
.getImageData(0, 0, fullWidth, fullHeight)
.data
.buffer
.asUint8List();
}