renderPage method
Renders a specific page of the document as an image. Parameters:
pageIndexThe index of the page to render.widthThe width of the rendered image in pixels.heightThe height of the rendered image in pixels.backgroundColorThe background color to use when rendering the page. Default is white. only Android PlatformdrawAnnotWhether to draw annotations on the rendered page. Default is true. only Android PlatformdrawFormWhether to draw form fields on the rendered page. Default is true. only Android PlatformcompressionThe compression format for the rendered image. Default is PNG. only Android Platform example:
var pageIndex = 0; // The index of the page to render
Size size = await document.getPageSize(pageIndex);
Uint8List imageData = await document.renderPage(pageIndex: pageIndex, width: size.width, height: size.height);
Implementation
Future<Uint8List> renderPage(
{required int pageIndex,
required int width,
required int height,
Color backgroundColor = Colors.white,
bool drawAnnot = true,
bool drawForm = true,
CPDFPageCompression compression = CPDFPageCompression.png}) async {
Uint8List imageData = await _channel.invokeMethod('render_page', {
'page_index': pageIndex,
'width': width,
'height': height,
'background_color': backgroundColor.toHex(),
'draw_annot' : drawAnnot,
'draw_form' : drawForm,
'compression': compression.name,
});
return imageData;
}