Annotation Rotation
Annotation rotation provides the functionality to rotate standard stamp annotations, custom stamp annotations, image annotations, and electronic signature annotations, allowing users to rotate annotations through a full range (-180~180 degrees). ComPDFKit offers convenient APIs for rotating annotations, along with demo demonstrations.
Rotating Annotations Programmatically
To rotate the annotation programmatically, you set it using two methods: SetSourceRect
in the CPDFAnnotation
class and SetRotation
in the CPDFAnnotationRotator
class.
CPDFAnnotation.SetSourceRect
The rectangular Rect before rotation. It's worth noting that this only needs to be refreshed when the annotation is scaled or moved, not when it is rotated.
CPDFAnnotationRotator.SetRotation
Sets the rotation angle of the annotation in degrees, with a range from -180 to 180.
Here is the example code for annotation rotation:
// Obtain the page object.
CPDFPage page = document.PageAtIndex(0);
// Create standard stamp annotation.
CPDFStampAnnotation standard = page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_STAMP) as CPDFStampAnnotation;
standard.SetStandardStamp("Approved");
// Sets the rectangle before annotation rotation.
standard.SetSourceRect(new CRect(100, 150, 250, 100));
// Sets the rotation Angle of the annotation.
standard.AnnotationRotator.SetRotation(45);
standard.UpdateAp();