// For complete examples and data files, please go to https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java
try {
AnnotationConfig cfg = Utilities.getConfiguration();
AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
annotator.getDocumentDataHandler();
InputStream cleanPdf = new FileInputStream(Utilities.storagePath + File.separator + fileName);
List<AnnotationInfo> annotations = new ArrayList<AnnotationInfo>();
// Arrow annotation
AnnotationInfo arrowAnnotation = new AnnotationInfo();
arrowAnnotation.setAnnotationPosition(new Point(852.0, 252.0));
arrowAnnotation.setBox(new Rectangle(279.4742f, 252.9241f, 129.9555f, -9.781596f));
arrowAnnotation.setPageNumber(0);
arrowAnnotation.setPenColor(1201033);
arrowAnnotation.setPenStyle((byte) 0);
arrowAnnotation.setPenWidth((byte) 1);
arrowAnnotation.setSvgPath("M279.47417840375584,252.92413145539905 L129.9554929577465,-9.781596244131455");
arrowAnnotation.setType(AnnotationType.Arrow);
arrowAnnotation.setCreatorName("Anonym A.");
annotations.add(arrowAnnotation);
// Add annotation to the document
InputStream result = annotator.exportAnnotationsToDocument(cleanPdf, annotations, DocumentType.Pdf);
// Save result stream to file.
OutputStream fileStream = new FileOutputStream(
Utilities.outputPath + File.separator + "annotated-arrow.pdf");
IOUtils.copy(result, fileStream);
} catch (Exception e) {
System.out.println("Exception:" + e.getMessage());
e.printStackTrace();
}