Skip to main content
January 11, 2017
Question

How to Rotate Stamps or Annotations via Javascript?

  • January 11, 2017
  • 1 reply
  • 4574 views

I am trying to automate the rotation of a given stamp that is duplicated across multiple pages. Typically I would attempt to script such procedure, but I lack information regarding the methods I have available. In what ways can you refer to an annotation, and what is the appropriate rotate method called?

The only rotation I managed to achieve was by selecting the stamp, then executing a command along the lines of " this.selectedAnnots[0].rotate = <angle to rotate>".

However, not only do I not want to select and execute the command (as that would be similar to manually rotating with the grip), but also, the rotation shrinks my stamp for some reason.

Is there a more appropriate way to do this? Note I am using the Standard Version of Acrobat.

Thanks

This topic has been closed for replies.

1 reply

Inspiring
January 12, 2017

To rotate an annotation without resizing, you'd also have to change the rect property, which you'll have to compute based on the rotation value you use. The following tutorial should help with some of the math involved: https://acrobatusers.com/tutorials/auto_placement_annotations

January 12, 2017

I read the article and I think I get the point of it. But it's difficult to see how that affects my rotation. I am rotating a stamp for example, so what property of that stamp am I trying to modify, and what function call allows me to do that?

The mentioned article makes sense to me in the context of auto positioning the stamp with respect to page boundaries, but it doesnt deal with rotation or dealing with an already existing stamp -- what function call do I use to modify the transform of an existing stamp or annotation?

Legend
January 12, 2017

Let's step back. Why do you reject setting the rotate property, surely the only way to rotate? George's reply indicated the only other property you need to set is text, which you must recalculate to include the revised element boundary.