Hi Kevin,

On 28.05.2013 17:28, Kevin Day wrote:
> Sorry, but there's no way that we can break encapsulation by exposing that
> field.

As I said you can still preserve the encapsulation by providing a
protected getter:

protected StringBuffer getStringBuffer() {
    return result;
}

However I don't see much sense in it, as result is declared as final.
Or you don't use "protected" in whole project at all?

Alternative is this operation:

protected void appendText(String s) {
    result.append(s);
}

but it's not very flexible. My opinion is: by hiding too much in the
class you are limiting the ways it can be customized and used. Usually
it ends with code duplication (copy-paste) across projects.

> I'm not following your logic about why you need access to the underlying
> StringBuffer - it would seem that using composition would be more
> appropriate.  Go ahead and lay out the algorithm you are thinking about
> using and I'll see if I can make some suggestions.

The class that I am implementing looks like following:

@Component
public class ImageAndTextTextExtractionStrategy extends
SimpleTextExtractionStrategy {

    @Autowired
    private OcrService ocrService;

    @Override
    pubic void renderImage(ImageRenderInfo renderInfo) {
        result.append(
            ocrService.ocrImage(
                renderInfo.getImage().getBufferedImage()));
    }
}

> I'll also mention that SimpleTextExtractionStrategy is really, really
> simple.  It was intended to provide a very simple example of how one might
> write their own extraction strategy.

It fit's my needs. Text flow in my case is always from top to bottom.
However sometimes the *whole page* is an image that needs to be OCR'ed.
No post-layouting is needed.

-- 
With best regards,
Dmitry

------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to