You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Shiva Kumar <sh...@pawaa.com> on 2015/06/05 07:37:05 UTC

WordToHtmlConverter -> More than one anchor found for a CharacterRun Object

Hi, In WordToHtmlConverter in this below method, I am getting more than one
anchor character in the same characterrun object, but here only one drawing
is extracted, what about remaining drawings, [it's missing out].

Please suggest any other idea for extracting all those drawings.

 

protected void processDrawnObject( HWPFDocument doc,

        CharacterRun characterRun, Element block )

{

      int anchorCnt = 0;

    if ( getPicturesManager() == null )

        return;

 

        char[] charChar = characterRun.text().toCharArray();

        for(char c : charChar)

         {

              if(c == 8)

               anchorCnt++

         }

 

         System.out.println(anchorCnt);   // gives three anchors count
anchorCnt -> 3

    // TODO: support headers

    OfficeDrawing officeDrawing = doc.getOfficeDrawingsMain()

            .getOfficeDrawingAt( characterRun.getStartOffset() );

 

    if ( officeDrawing == null )

    {

        logger.log( POILogger.WARN, "Characters #" + characterRun

                + " references missing drawn object" );

        return;

    }

 

    byte[] pictureData = officeDrawing.getPictureData();

    if ( pictureData == null )

        // usual shape?

        return;

 

    float width = ( officeDrawing.getRectangleRight() - officeDrawing

            .getRectangleLeft() ) / AbstractWordUtils.TWIPS_PER_INCH;

    float height = ( officeDrawing.getRectangleBottom() - officeDrawing

            .getRectangleTop() ) / AbstractWordUtils.TWIPS_PER_INCH;

 

    final PictureType type = PictureType.findMatchingType( pictureData );

    String path = getPicturesManager()

            .savePicture( pictureData, type,

                    "s" + characterRun.getStartOffset() + "." + type,

                    width, height );

 

    processDrawnObject( doc, characterRun, officeDrawing, path, block );

}

 

 

Thank You

 

SHIVA KUMAR K R

Phone : +91 9844831440

Linkedin :  <http://in.linkedin.com/in/shivakumarkr/> shiva_kumar_k_r