title: GET TEXT FROM IMAGE EMBEDDED IN A .docx FILE USING TIKA
body: <p>I've been working on Text Extractor that works on .docx file using Tika. And it is working file for basic text and text in tables and textboxes, but it fails for images.</p>
  
  <p>How do I get text from Image, tesseract along with tika can be used to get text from an image alone but for that I would need to extract out the image from document. How do I do this?</p>
  
  <p>Kindly help if anybody has worked upon something like this.</p>
  
  <p>This the code that works fine for text, textbox and tables,but not for images:</p>
  
  <pre><code>public class BasicDocumentExtractor {
  public static void main(final String[] args) throws IOException,SAXException, TikaException { 
  
          //detecting the file type 
          BodyContentHandler handler = new BodyContentHandler(); 
          Metadata metadata = new Metadata(); 
  
          FileInputStream inputstream=new FileInputStream(new File("D:\\Nidhi\\sw\\ws\\Hello.docx")); 
          ParseContext pcontext=new ParseContext(); 
  
          //OOXml parser 
          OOXMLParser msofficeparser=new OOXMLParser (); 
          msofficeparser.parse(inputstream, handler,metadata,pcontext); 
          System.out.println("Contents of the document:" +handler.toString()); 
  
          /*System.out.println("Metadata of the document:"); 
          String[] metadataNames = metadata.names(); 
  
          for(String name : metadataNames){ 
              System.out.println(name + ": " + metadata.get(name)); 
          }*/
  }
  </code></pre>
  
  <p>}</p>