PdfImage.file constructor
PdfImage.file(
- PdfDocument pdfDocument, {
- required Uint8List bytes,
- PdfImageOrientation orientation = PdfImageOrientation.topLeft,
Create an image from an image file
Implementation
factory PdfImage.file(
PdfDocument pdfDocument, {
required Uint8List bytes,
PdfImageOrientation orientation = PdfImageOrientation.topLeft,
}) {
if (im.JpegDecoder().isValidFile(bytes)) {
return PdfImage.jpeg(pdfDocument, image: bytes);
}
final image = im.decodeImage(bytes);
if (image == null) {
throw 'Unable to decode image';
}
return PdfImage.fromImage(
pdfDocument,
image: image,
orientation: orientation,
);
}