Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Created August 6, 2019 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GroupDocsGists/705c29f24cf3c7a5efffe88768bde0a0 to your computer and use it in GitHub Desktop.
Save GroupDocsGists/705c29f24cf3c7a5efffe88768bde0a0 to your computer and use it in GitHub Desktop.
// For complete examples and data files, please go to https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java
AnnotationImageHandler annotator = new AnnotationImageHandler(Utilities.getConfiguration());
InputStream inputStream = new FileInputStream("E:\sample.pdf");
List<AnnotationInfo> annotations = new ArrayList<AnnotationInfo>();
// Ellipse annotation
AnnotationInfo ellipseAnnotation = new AnnotationInfo();
ellipseAnnotation.setBox(new Rectangle(430f, 272f, 66f, 51f));
ellipseAnnotation.setPageNumber(0);
ellipseAnnotation.setType(AnnotationType.Ellipse);
ellipseAnnotation.setCreatorName("Anonym A.");
annotations.add(ellipseAnnotation);
// Add annotation to the document
InputStream result = annotator.exportAnnotationsToDocument(inputStream, annotations, DocumentType.Pdf);
// Save result stream to file.
OutputStream fileStream = new FileOutputStream("E:\annotated-ellipsed.pdf");
IOUtils.copy(result, fileStream);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment