createPhotoFromPdfPage static method
Implementation
static Future<ImageData> createPhotoFromPdfPage(
String memberMediumDocumentID, String filePath, int pageNumber) async {
final document = await PdfDocument.openFile(filePath);
final page = await document.getPage(pageNumber);
final pageImage = await page.render(width: page.width, height: page.height);
await page.close();
if (pageImage == null) {
throw Exception("Can't find render image $filePath");
}
var img = imgpackage.decodeImage(pageImage.bytes);
if (img == null) {
throw Exception('Could not decode image');
}
return ImageData(
baseName: BaseNameHelper.baseName(memberMediumDocumentID, filePath),
width: img.width,
height: img.height,
data: pageImage.bytes);
}