Skip to content

Instantly share code, notes, and snippets.

@atirtahirgroupdocs
Last active July 6, 2017 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atirtahirgroupdocs/dea82194e246fa18f2ad3369914316c8 to your computer and use it in GitHub Desktop.
Save atirtahirgroupdocs/dea82194e246fa18f2ad3369914316c8 to your computer and use it in GitHub Desktop.
// 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