GroupDocsGists
10/24/2017 - 1:18 PM

Examples-GroupDocs.Annotation.Examples.Java-src-main-java-GroupDocs-Annotation-Examples-Java-AnnotateDocuments-addStrikeoutAnnotationInWords.java

// 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);
	InputStream cleanDoc = new FileInputStream(Utilities.storagePath + File.separator + fileName);
	List<AnnotationInfo> annotations = new ArrayList<AnnotationInfo>();
	// init strikeout annotations
	AnnotationInfo strikeoutAnnotation = new AnnotationInfo();
	strikeoutAnnotation.setBox(new Rectangle(87.9f, 276.5f, 435.7f, 87f));
	strikeoutAnnotation.setPageNumber(1);
	strikeoutAnnotation.setPenColor(1201033);
	strikeoutAnnotation.setSvgPath(
			"[{\"x\":208.392,\"y\":313.088},{\"x\":519.659,\"y\":313.088},{\"x\":208.392,\"y\":304.088},{\"x\":519.659,\"y\":304.088}]");
	strikeoutAnnotation.setType(AnnotationType.TextStrikeout);
	annotations.add(strikeoutAnnotation);
	// Add annotation to the document
	InputStream result = annotator.exportAnnotationsToDocument(cleanDoc, annotations, DocumentType.Words);
	// Save result stream to file.
	OutputStream fileStream = new FileOutputStream(
			Utilities.outputPath + File.separator + "words-annotated.docx");
	System.out.println(result.available());
	IOUtils.copy(result, fileStream);
} catch (Exception e) {
	System.out.println("Exception: " + e.getMessage());
	e.printStackTrace();
}