toOffset method

Offset toOffset({
  1. required PdfPage page,
  2. Size? scaledPageSize,
  3. int? rotation,
})

Convert to Offset in Flutter coordinate. page is the page to convert the rectangle. scaledPageSize is the scaled page size to scale the rectangle. If not specified, PdfPage.size is used. rotation is the rotation of the page. If not specified, PdfPage.rotation is used.

Implementation

Offset toOffset({required PdfPage page, Size? scaledPageSize, int? rotation}) {
  final rotated = rotate(rotation ?? page.rotation.index, page);
  final scale = scaledPageSize == null ? 1.0 : scaledPageSize.height / page.height;
  return Offset(rotated.x * scale, (page.height - rotated.y) * scale);
}