Last active
July 24, 2017 09:03
-
-
Save atirtahirgroupdocs/f7328001ea72b796d42b50a4e893ebe9 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
AnnotationConfig cfg = Utilities.getConfiguration(); | |
AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); | |
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("Word: '" + words[j] + "'"); | |
System.out.println("Word distance from left: " + rowData.getTextCoordinates().get(coordinateIndex)); | |
System.out.println("Word width: " + rowData.getTextCoordinates().get(coordinateIndex + 1)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment