renderPdfPage method
Future<Uint8List?>
renderPdfPage({
- required int pdf,
- required int page,
- int? x,
- int? y,
- int? width,
- int? height,
- double? scale,
- Color background = const Color(0xFFFFFFFF),
override
Converts a given page
from a given pdf
to a bitmap.
Optionally crop the output image to a given x
and y
coordinate with a given width
, height
.
With the scale
argument you can control the output resolution.
Default scale is 1
which means that the output image has exactly the size of the PDF.
Optionally set the background
color which will be used instead of transparency.
Implementation
@override
Future<Uint8List?> renderPdfPage({
required int pdf,
required int page,
int? x,
int? y,
int? width,
int? height,
double? scale,
Color background = const Color(0xFFFFFFFF),
}) async {
PdfImageRendererPageSize size;
if (width == null || height == null) {
size = await getPdfPageSize(pdf: pdf, page: page);
width ??= size.width;
height ??= size.height;
}
final image = await methodChannel.invokeMethod<Uint8List>('renderPDFPage', {
'pdf': pdf,
'page': page,
'x': x,
'y': y,
'width': width,
'height': height,
'scale': scale,
'background': '#${background.value.toRadixString(16)}',
});
return image;
}