Index: /gs3-installations/intermuse/trunk/sites/intermuse/collect/programmes/js/document_viewer.js
===================================================================
--- /gs3-installations/intermuse/trunk/sites/intermuse/collect/programmes/js/document_viewer.js	(revision 36993)
+++ /gs3-installations/intermuse/trunk/sites/intermuse/collect/programmes/js/document_viewer.js	(revision 36993)
@@ -0,0 +1,107 @@
+/*
+
+https://stackoverflow.com/questions/68395710/building-a-bounding-box-surrounding-text-in-google-vision-api-to-extract-the-tex
+
+def get_text_within(document, x1, y1, x2, y2):
+text = ""
+for page in document.pages:
+    for block in page.blocks:
+        for paragraph in block.paragraphs:
+            for word in paragraph.words:
+                for symbol in word.symbols:
+                    min_x = min(symbol.bounding_box.vertices[0].x, symbol.bounding_box.vertices[1].x,
+                                symbol.bounding_box.vertices[2].x, symbol.bounding_box.vertices[3].x)
+                    max_x = max(symbol.bounding_box.vertices[0].x, symbol.bounding_box.vertices[1].x,
+                                symbol.bounding_box.vertices[2].x, symbol.bounding_box.vertices[3].x)
+                    min_y = min(symbol.bounding_box.vertices[0].y, symbol.bounding_box.vertices[1].y,
+                                symbol.bounding_box.vertices[2].y, symbol.bounding_box.vertices[3].y)
+                    max_y = max(symbol.bounding_box.vertices[0].y, symbol.bounding_box.vertices[1].y,
+                                symbol.bounding_box.vertices[2].y, symbol.bounding_box.vertices[3].y)
+                    if (min_x >= x1 and max_x <= x2 and min_y >= y1 and max_y <= y2):
+                        text += symbol.text
+                    if (symbol.property.detected_break.type == 1 or
+                            symbol.property.detected_break.type == 3):
+                        text += ' '
+                    if (symbol.property.detected_break.type == 2):
+                        text += '\t'
+                    if (symbol.property.detected_break.type == 5):
+                        text += '\n'
+return text
+
+*/
+
+
+/*
+
+https://stackoverflow.com/questions/57071788/google-vision-api-text-detection-display-words-by-block
+
+
+https://gist.github.com/UBISOFT-1/f00e4d22790f4af378d70b237fa56ca9
+
+    response = client.text_detection(image=image)
+    # The actual response for the first page of the input file.
+    breaks = vision.enums.TextAnnotation.DetectedBreak.BreakType
+    paragraphs = []
+    lines = []
+    # extract text by block of detection
+    for page in response.full_text_annotation.pages:
+        for block in page.blocks:
+            for paragraph in block.paragraphs:
+                para = ""
+                line = ""
+                suppose = str(paragraph.bounding_box)
+                suppose = suppose.replace('vertices ','')
+                print(suppose)
+                for word in paragraph.words:
+                    for symbol in word.symbols:
+                        line += symbol.text
+                        if symbol.property.detected_break.type == breaks.SPACE:
+                            line += ' '
+                        if symbol.property.detected_break.type == breaks.EOL_SURE_SPACE:
+                            line += ' '
+                            lines.append(line)
+                            para += line
+                            line = ''
+                        if symbol.property.detected_break.type == breaks.LINE_BREAK:
+                            lines.append(line)
+                            para += line
+                            line = ''
+            paragraphs.append(para)
+
+
+    return "\n".join(paragraphs)
+
+
+
+
+https://blog.searce.com/tips-tricks-for-using-google-vision-api-for-text-detection-2d6d1e0c6361
+
+def draw_boxes(image, bounds, color,width=5):
+    draw = ImageDraw.Draw(image)
+    for bound in bounds:
+        draw.line([
+            bound.vertices[0].x, bound.vertices[0].y,
+            bound.vertices[1].x, bound.vertices[1].y,
+            bound.vertices[2].x, bound.vertices[2].y,
+            bound.vertices[3].x, bound.vertices[3].y,
+            bound.vertices[0].x, bound.vertices[0].y],fill=color, width=width)
+    return image
+def get_document_bounds(response, feature):
+    for i,page in enumerate(document.pages):
+        for block in page.blocks:
+            if feature==FeatureType.BLOCK:
+                bounds.append(block.bounding_box)
+            for paragraph in block.paragraphs:
+                if feature==FeatureType.PARA:
+                    bounds.append(paragraph.bounding_box)
+                for word in paragraph.words:
+                    for symbol in word.symbols:
+                        if (feature == FeatureType.SYMBOL):
+                            bounds.append(symbol.bounding_box)
+                    if (feature == FeatureType.WORD):
+                        bounds.append(word.bounding_box)
+    return bounds
+bounds=get_document_bounds(response, FeatureType.WORD)
+draw_boxes(image,bounds, 'yellow')
+
+*/
