poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shiva Kumar" <shiv...@pawaa.com>
Subject WordToHtmlConverter -> More than one anchor found for a CharacterRun Object
Date Fri, 05 Jun 2015 05:37:05 GMT
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

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message