WebViewer Version: 8.0.0
I’ve noticed there are some typing issues in the webviewer sdk. Specifically all these methods:
- Core.Math.Rect.GetCenter()
- Core.Math.Rect.GetTopRight()
- Core.Math.Rect.GetTopLeft()
- Core.Math.Rect.GetBottomRight()
- Core.Math.Rect.GetBottomLeft()
Have a return type of number, while they are actually returning a Core.Math.Point. This is also referred to in the documentation, which is therefore contradicting itself. It describes the method as returning a Point, but the return parameter is stated as a number: PDFTron WebViewer Class: Rect
This is messing up the typescript compiler, which expects the return type given in PDFTron’s types.d.ts
:
/**
* Gets a {@link Core.Math.Point Point} that is at the top-left of the rect.
* @returns A point at the top-left of the rect
*/
getTopLeft(): number;
A workaround is to manually cast it to the appropriate type:
const topLeft = rect.getTopLeft() as unknown as Core.Math.Point;
Would be great if you could fix this in the next version!