renderAnnotationAppearance method
Future<Uint8List>
renderAnnotationAppearance(
- CPDFAnnotation annotation, {
- CPDFAnnotationRenderOptions options = const CPDFAnnotationRenderOptions(),
Renders the current appearance of an annotation to image bytes.
This API renders the annotation appearance from the PDF page. It does not return the original source asset for annotations backed by external content.
Parameters:
annotationThe target annotation.optionsRendering options that control output resolution and compression.
example:
final annotations = await document.pageAtIndex(0).getAnnotations();
final annotation = annotations.first;
final imageBytes = await document.renderAnnotationAppearance(
annotation,
options: const CPDFAnnotationRenderOptions(scale: 4.0),
);
Implementation
Future<Uint8List> renderAnnotationAppearance(CPDFAnnotation annotation,
{CPDFAnnotationRenderOptions options =
const CPDFAnnotationRenderOptions()}) async {
options.validate();
final result = await _channel.invokeMethod('render_annotation_appearance', {
'page_index': annotation.page,
'uuid': annotation.uuid,
'options': options.toJson(),
});
if (result is Uint8List) {
return result;
} else if (result is Map && result.containsKey('error')) {
throw Exception('renderAnnotationAppearance failed: ${result['error']}');
} else {
throw Exception(
'renderAnnotationAppearance failed: unexpected result type ${result.runtimeType}');
}
}