buildImage method

  1. @override
PdfImage buildImage(
  1. Context context, {
  2. int? width,
  3. int? height,
})
override

Implementation

@override
PdfImage buildImage(Context context, {int? width, int? height}) {
  if (width == null) {
    return PdfImage.file(context.document, bytes: bytes);
  }

  final image = im.decodeImage(bytes);

  if (image == null) {
    throw Exception('Unable decode the image');
  }

  final resized = im.copyResize(image, width: width);
  return PdfImage.fromImage(context.document, image: resized);
}