GroupDocsGists
10/24/2017 - 1:07 PM

getDocInfoForDiagram.java

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));
	}
     }
}