Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save groupdocs-com-kb/faf87e3e58863788231d2eb3dd1e6b3f to your computer and use it in GitHub Desktop.
Save groupdocs-com-kb/faf87e3e58863788231d2eb3dd1e6b3f to your computer and use it in GitHub Desktop.
Add Distance Annotation to JPG using Java. For more information, please follow link: https://kb.groupdocs.com/annotation/java/add-distance-annotation-to-jpg-using-java/
import com.groupdocs.annotation.Annotator;
import com.groupdocs.annotation.licenses.License;
import com.groupdocs.annotation.models.PenStyle;
import com.groupdocs.annotation.models.Rectangle;
import com.groupdocs.annotation.models.annotationmodels.DistanceAnnotation;
import java.util.Calendar;
public class AddDistanceAnnotationtoJPGUsingJava {
public static void main(String[] args) {
// Set License to avoid the limitations of Annotation library
License license = new License();
license.setLicense("GroupDocs.Annotation.lic");
// Create an instance of Annotator class
Annotator annotator = new Annotator("input.jpg");
// Create an instance of DistanceAnnotation class and set options
DistanceAnnotation distance = new DistanceAnnotation();
distance.setBox(new Rectangle(200, 150, 200, 30));
distance.setCreatedOn(Calendar.getInstance().getTime());
distance.setMessage("This is distance annotation");
distance.setOpacity(0.7);
distance.setPageNumber(0);
distance.setPenColor(65535);
distance.setPenStyle(PenStyle.DOT);
distance.setPenWidth((byte) 3);
// Add distance annotation
annotator.add(distance);
// Save JPG to disk
annotator.save("output.jpg");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment