Quad.toRect() not working as expected

WebViewer Version: 8.1.0

Core.Math.Quad method “toRect()” not working as expected


I’m having an issue when trying to convert a Quad into a Rect using the method “toRect()”. It seems to return a wrong Rect object, that seems to have only one Point (x1, y1 is equal to x2, y2) and it is a square (height and width have always the same value).

Steps to reproduce it:

annotation <-- this is a TextHighlightAnnotation
const rects = annotation.Quads.map(quad => {
  // on a side note calling directly quad.toRect() doesn't work
  const {x1, y1, x2, y2, x3, y3, x4, y4} = quad; 
  const realQuad = new Core.Math.Quad(x1, y1, x2, y2, x3, y3, x4, y4);
  return realQuad.toRect();

When I try to print the “toRect” function it gives this result:

function function(){return new ba.a(this.x4,this.x4,this.x2,this.x2)}

but shoudn’t it be more like:

function function(){return new ba.a(this.x4,this.y4,this.x2,this.y2)}


For the moment I bypassed the issue by creating the Rect object directly.

Edit to add more context:
I’m not using the default viewer, I’m implementing a custom viewer.

Thank you! :slight_smile:

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:


Hello there.

Thanks for reporting this issue.

The fix has been merged and will be available on tomorrow’s nightly 8.1 stable build. you can find it here: https://www.pdftron.com/nightly/#stable/2021-11-24/webviewer/

Let me know how it works for you and if you have further questions.

Best Regards,
Diego Felix
Web Software Developer
PDFTron Systems, Inc.

CONFIDENTIALITY NOTICE: This message (and any attachment to it) is intended only for the use of the individual or entity to which it is addressed in the header, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. Any reproduction, distribution, modification or use of the contents of this message (and any attachment to it) by any individual or entity other than the intended recipient is prohibited. If you have received this communication in error, please notify us immediately and delete the original.

It works now, thanks! :slight_smile: