pointFromTopLeft method
Converts a "top-left" point to the user space.
Implementation
PdfPoint pointFromTopLeft(double x, double y) {
// First move from the display point to the user unit.
final xr = x / userUnit;
final yr = y / userUnit;
// Then undo the rotation, reaching the top-left system of the unrotated
// page, with origin at the upper-left corner of the box.
final double px;
final double py;
switch (rotation) {
case PdfPageRotation.none:
px = xr;
py = yr;
case PdfPageRotation.rotate90:
px = yr;
py = box.height - xr;
case PdfPageRotation.rotate180:
px = box.width - xr;
py = box.height - yr;
case PdfPageRotation.rotate270:
px = box.width - yr;
py = xr;
}
// Finally apply the box origin and flip the y axis.
return PdfPoint(box.left + px, box.top - py);
}