Skip to main content
daitranthanhoa
Inspiring
Apr 1, 2017 11:08 AM UTC
Answered

How can get coordinates of PDEElement?

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 is closed to new replies. Start a new post to keep the conversation going.
lrosenth
lrosenthCorrect answer
Adobe Employee
Apr 1, 2017 11:17 PM UTC

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?

4 replies

lrosenth
Adobe Employee
lrosenthCorrect answer
Adobe Employee
Apr 1, 2017 11:17 PM UTC

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?

Translate
daitranthanhoa
Inspiring
Apr 3, 2017 2:55 AM UTC

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?

Translate
daitranthanhoa
Inspiring
Apr 3, 2017 4:21 AM UTC

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

Translate