GroupDocsGists
10/24/2017 - 1:09 PM

Examples-GroupDocs.Annotation.Examples.Java-src-main-java-GroupDocs-Annotation-Examples-Java-WordsAnnotation-importingAnnotationsFromWordDoc.java

// For complete examples and data files, please go to https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java
AnnotationConfig cfg = Utilities.getConfiguration();
AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
// Importing annotations from Words document
FileInputStream stream = new FileInputStream(Utilities.storagePath + File.separator + fileName);
AnnotationInfo[] annotations = annotator.importAnnotations(stream, DocumentType.Words);
 
// Export imported annotation to another document 
InputStream clearDocument = new FileInputStream(Utilities.storagePath + File.separator + "Clear.docx");
InputStream output = annotator.exportAnnotationsToDocument(clearDocument, Arrays.asList(annotations), DocumentType.Words);
 
// Save results after export
OutputStream fileStream = new FileOutputStream(
		Utilities.outputPath + File.separator + "words-annotated.docx");
System.out.println(output.available());
IOUtils.copy(output, fileStream);