placeImage method
Places imageBytes (PNG or JPEG) centered on (x, y) in page
space, maxSize points on its longest side, preserving the image's
aspect ratio and capped at 90% of the page so it is never larger than
the paper. The centre is the point given, so an image dropped at the
edge hangs off the page rather than jumping inward.
Returns false when the bytes aren't a decodable PNG or JPEG.
Implementation
bool placeImage(
int pageIndex,
double x,
double y,
Uint8List imageBytes, {
double maxSize = 200,
}) {
final PdfEmbeddableImage image;
try {
image = PdfEmbeddableImage.decode(imageBytes);
} catch (_) {
return false;
}
return _placeDecodedImage(pageIndex, x, y, image, maxSize: maxSize);
}