Interface IDocumentReader


@PublicAPI public interface IDocumentReader
The IDocumentReader interface gives the functionality to read the Chemical Structures from a given document.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the office document stream.
    Reads all the molecules from the given document
    chemaxon.formats.documents.jchemoffice.BatchProcessingException
    Gives back all exceptions occurred while processing the document.
    boolean
    Determines if the document contains JCO structure.
    Determines if the given POI object can be handled as a JCO object with molecule content.
  • Method Details

    • getAllStructures

      List<MoleculeMap> getAllStructures() throws Exception
      Reads all the molecules from the given document
      Returns:
      MoleculeMap array with the molecules and their locations
      Throws:
      Exception
    • isDocumentJCO

      boolean isDocumentJCO()
      Determines if the document contains JCO structure.
      Returns:
      True if the document contains JCO structure.
    • isObjectJCO

      MoleculeMap isObjectJCO(Object range)
      Determines if the given POI object can be handled as a JCO object with molecule content.

      Example how to use the isObjectJCO from PowerPoint:

       XMLSlideShow pptx = new XMLSlideShow(inputStream);
       XSLFShape groupShape = pptx.getSlides().get(0).getShapes().get(0);
       XSLFShape pictureShape = null;
       List innerShapes = ((XSLFGroupShape) groupShape).getShapes();
       for (XSLFShape innerShape : innerShapes) {
           if (innerShape.getClass().getName().equals("org.apache.poi.xslf.usermodel.XSLFPictureShape")) {
               pictureShape = innerShape;
              }
       }
       inputStream.close();
       IDocumentReader reader = DocumentHandlerFactory.CreateReader(inputStream);
       -- Check group shape
       MoleculeMap map = reader.isObjectJCO(groupShape);
       -- or Check picture shape
       MoleculeMap map = reader.isObjectJCO(pictureShape);
      
       

      Example how to use the isObjectJCO from Word:

       XWPFDocument doc = new XWPFDocument(inputStream);
       XWPFParagraph paragraph = doc.getTables().get(0).getRow(0).getTableCells().get(0).getParagraphs().get(0);
       XWPFRun run = paragraph.getRuns().get(0);
       inputStream.close();
       IDocumentReader reader = DocumentHandlerFactory.CreateReader(inputStream);
       -- Check the paragraph
       MoleculeMap mapPicture = reader.isObjectJCO(paragraph);
       -- Or check the run
       MoleculeMap mapPicture = reader.isObjectJCO(run);
       inputStream.close();
       reader.close();
       
      Parameters:
      range - - The POI object (i.e.: groupShape, pictureShape, paragraph, run)
      Returns:
      If the passed parameter is a JCO object it returns the MoleculeMap from it otherwise returns an empty MoleculeMap object.
    • close

      void close() throws IOException
      Closes the office document stream.
      Throws:
      IOException
    • getExceptions

      chemaxon.formats.documents.jchemoffice.BatchProcessingException getExceptions()
      Gives back all exceptions occurred while processing the document.
      Returns:
      Returns with a throwable IOException that collects inner exceptions occurred in the batch processing.