According to some q&a I understand that iText text extraction tool is not capable to recognize underline and strikethrough font attributes due to the PDF specification not supporting it. To allow recognition I did update PdfContentStreamProcessor.java by adding shape subpath recognition. I did also add ShapeRenderInfo.java to contain graphics info.
For instance recognizing underline means start from a TextRenderInfo object and scan all ShapeRenderInfo to try to match (rectangle contains/intersect ... etc)) the By reading q&a I did understand that iText text extraction tool is not supporting underline (strike-through, over-strike, ...) font attributes recognitions due to PDF specification allowing underline only by drawing shapes under text. To achieve underline recognition I did update PdfContentStreamProcessor.java by adding shape sub-path management, I did also add ShapeRenderInfo.java to contain graphics rendering parameters.
My idea is to have underline recognized by getting Rectangles2D from both TextRenderInfo and ShapeRenderInfo and by checking for containment/intersection between them.
What I'm doing implies a noticeable change in how currently iText delivers events to RenderListener, because they are currently propagated as encountered in the pdf streams, on the contrary I need that XxxxxRenderObjects are collected first, then delivered at page end, thus allowing searching through rectangles.
In brief: isUnderline() method on TextRenderInfo, will start scanning into collected shapes trying to match graphic objects rectangles against text rectangles.
Beside the need to update RenderListener.java to allow ShapeRender events propagation, I did identified the following possible solutions to implement the logic change:
1) update PdfContentStreamProcessor implementing the new event delivery policy
2) shield PdfContentStreamProcessor and RenderListener(s) by inserting a new layer (a new listener) capable to handle the logic
My question to the iText team is: What is the best choice? Have you any further suggestion?
Thank you beforehand
JQ.