Skip to main content
daitranthanhoa
Inspiring
April 1, 2017
Answered

How can get coordinates of PDEElement?

  • April 1, 2017
  • 1 reply
  • 975 views

This is my code add a Rectangle to PDEElement:

AVRect rect;

PDEElementGetBBox (pdeElement, &bbox);

AVPageViewRectToDevice (pageView, &bbox, &rect);

sprintf(jsScript, "var a = this.addAnnot({page:%d,type:'Square'}); a.name='%s';a.rect=[%d,%d,%d,%d];  ",i,"P"+j, rect.left ,rect.top , rect.right, rect.bottom);   AFExecuteThisScript (myPDDoc , jsScript, NULL);

Position of Rectangle  in Result not correct.

How can get coordinates of PDEElement?

Thanks all.

This topic has been closed for replies.
Correct answer lrosenth

Why are you converting to device rects. Skip that step and you should be fine.

BUT if you are already using the C++ APIs, why switch to JavaScript? Why not do all this using PD calls such as PDPageAddAnnot?

1 reply

lrosenth
Adobe Employee
lrosenthCorrect answer
Adobe Employee
April 1, 2017

Why are you converting to device rects. Skip that step and you should be fine.

BUT if you are already using the C++ APIs, why switch to JavaScript? Why not do all this using PD calls such as PDPageAddAnnot?

daitranthanhoa
Inspiring
April 3, 2017

I'm sorry, I had try this code and it add ok, but not exist color, so i can't see rectangle.

PDAnnot annot;

//Create a PDAnnot object

  annot = PDPageCreateAnnot (pdPage, ASAtomFromString("Square"),&bbox);

  PDPageAddAnnot(pdPage,-2, annot);

How set boder color of rectangle?

daitranthanhoa
Inspiring
April 3, 2017

Thanks, i had can set boder color , found at https://forums.adobe.com/thread/1517372?q=change%20color