Last active
July 6, 2017 10:01
-
-
Save atirtahirgroupdocs/dea82194e246fa18f2ad3369914316c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
annotator.createDocument(fileName); | |
DocumentInfoContainer documentInfoContainer = annotator.getDocumentInfo(fileName); | |
// Go through all pages | |
for (PageData pageData : documentInfoContainer.getPages()) | |
{ | |
System.out.println("Page number: " + pageData.getNumber()); | |
//Go through all page rows | |
for(int i = 0; i < pageData.getRows().size(); i++) | |
{ | |
RowData rowData = pageData.getRows().get(i); | |
// Write data to console | |
System.out.println("Row: " + (i + 1)); | |
System.out.println("Text: " + rowData.getText()); | |
System.out.println("Text width: " + rowData.getLineWidth()); | |
System.out.println("Text height: " + rowData.getLineHeight()); | |
System.out.println("Distance from left: " + rowData.getLineLeft()); | |
System.out.println("Distance from top: " + rowData.getLineTop()); | |
// Get words | |
String[] words = rowData.getText().split(" "); | |
// Go through all word coordinates | |
for(int j = 0; j < words.length; j++) | |
{ | |
int coordinateIndex = j == 0 ? 0 : j + 1; | |
// Write data to console | |
System.out.println(); | |
System.out.println("Word:'" + words[j] + "'"); | |
System.out.println("Word distance from left: " + rowData.getTextCoordinates().get(coordinateIndex)); | |
System.out.println("Word width: " + rowData.getTextCoordinates().get(coordinateIndex + 1)); | |
System.out.println(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment