physicalDimension property

Size physicalDimension

Size of an image

//Creates a new PDF document.
PdfDocument doc = PdfDocument();
//Create a PDF image instance.
PdfImage image = PdfBitmap(imageData);
//Gets the size of an image
Size size = image.physicalDimension;
//Draw the image with image's width and height.
doc.pages
  .add()
  .graphics
  .drawImage(image, Rect.fromLTWH(0, 0, size.width, size.height));
//Saves the document.
List<int> bytes = doc.save();
//Dispose the document.
doc.dispose();

Implementation

Size get physicalDimension => Size(width.toDouble(), height.toDouble());