Incorrect return type for Core.Math.Rect.Get*SomePoint*()

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!

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:


Thanks for the report! It looks like we recently identified this as well and actually already have it fixed in our nightly experimental build which means it will be part of our next official release. If you want to test it out this link shows how you can get our nightly builds

1 Like