GroupDocsGists
10/24/2017 - 1:18 PM

Examples-GroupDocs.Annotation.Examples.Java-src-main-java-GroupDocs-Annotation-Examples-Java-AnnotateDocuments-addStrikeOutAnnotationInPDF.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);
	annotator.getDocumentDataHandler();
	InputStream cleanPdf = new FileInputStream(Utilities.storagePath + File.separator + fileName);
	List<AnnotationInfo> annotations = new ArrayList<AnnotationInfo>();
	// Text strikeout annotation
	AnnotationInfo strikeoutAnnotation = new AnnotationInfo();
	strikeoutAnnotation.setAnnotationPosition(new Point(852.0, 154.31));
	strikeoutAnnotation.setBox(new Rectangle(68, 154, 102, 9));
	strikeoutAnnotation.setPageNumber(0);
	strikeoutAnnotation.setPenColor(0);
	strikeoutAnnotation.setType(AnnotationType.TextStrikeout);
	strikeoutAnnotation.setCreatorName("Anonym A.");
	annotations.add(strikeoutAnnotation);
	// 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-strikeout.pdf");
	IOUtils.copy(result, fileStream);
} catch (Exception e) {
	System.out.println("Exception:" + e.getMessage());
	e.printStackTrace();
}