CPDFImageAnnotation.fromJson constructor
Creates an image annotation from serialized JSON data.
Use this to restore annotations returned by ComPDFKit APIs or loaded from a previously persisted payload.
Example:
final annotation = CPDFImageAnnotation.fromJson({
'type': 'pictures',
'page': 0,
'uuid': 'annotation-id',
'rect': {
'left': 80.0,
'top': 120.0,
'right': 220.0,
'bottom': 260.0,
},
'imageData': {
'type': 'asset',
'data': 'assets/images/stamp.png',
},
});
Implementation
factory CPDFImageAnnotation.fromJson(Map<String, dynamic> json) {
final common = CPDFAnnotation.fromJson(json);
final imageDataJson = json['imageData'];
return CPDFImageAnnotation(
title: common.title,
content: common.content,
createDate: common.createDate,
page: common.page,
uuid: common.uuid,
rect: common.rect,
image: json['image'],
imageData: imageDataJson is Map<String, dynamic>
? CPDFImageData.fromJson(imageDataJson)
: imageDataJson is Map
? CPDFImageData.fromJson(Map<String, dynamic>.from(imageDataJson))
: null,
);
}