renderPDFPage static method
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
static 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);
if (width == null) width = size.width;
if (height == null) height = size.height;
}
final image = await _channel.invokeMethod<Uint8List>('renderPDFPage', {
'pdf': pdf,
'page': page,
'x': x,
'y': y,
'width': width,
'height': height,
'scale': scale,
'background': '#${background.value.toRadixString(16)}',
});
return image;
}