PdfImage.file constructor

PdfImage.file(
  1. PdfDocument pdfDocument, {
  2. required Uint8List bytes,
  3. 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,
  );
}