I have some tricky PDF files contains white text. To don't render it in text stripper, I override ProcessTextPosition method:
private static final int COLOR_WHITE = 16777215;
@Override
protected void processTextPosition(TextPosition text) {
PDGraphicsState gs = getGraphicsState();
PDColor nonStrokingColor = gs.getNonStrokingColor();
try {
if (nonStrokingColor.toRGB() != COLOR_WHITE) {
super.processTextPosition(text);
}
} catch (IOException e) {
logger.error("Could not convert stroking color to RGB", e);
}
}
However, sometimes I still need to render such white text- when it's placed on color background. As I understand, this is usually some filled rectangle under it, but I don't know how to handle it in ProcessTextPosition. Is there any way to do that? File example: example. Here "INCOME" is white on green rectangle, also "Huron account" is white text on blue rectangle.