toRect method
Convert to Rect 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
Rect toRect({
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 Rect.fromLTRB(
rotated.left * scale,
(page.height - rotated.top) * scale,
rotated.right * scale,
(page.height - rotated.bottom) * scale,
);
}