RED-4875 - first implementation of hasInvisibleText()
This commit is contained in:
parent
392db3b339
commit
41832f9897
@ -118,6 +118,8 @@ public class InvisibleElementRemovalService {
|
||||
log.info("Finished removing invisible Elements");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void removeClippedElementsAndInvisibleTextAndRememberOverlappedElements(Page page,
|
||||
ElementWriter writer,
|
||||
InvisibleElementRemovalContext context) throws PDFNetException {
|
||||
@ -150,7 +152,23 @@ public class InvisibleElementRemovalService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
public boolean hasInvisibleText(PDFDoc pdfDoc) {
|
||||
ElementReader reader = new ElementReader();
|
||||
for (PageIterator iterator = pdfDoc.getPageIterator(); iterator.hasNext(); ) {
|
||||
Page page = iterator.next();
|
||||
for (Element element = reader.next(); element != null; element = reader.next()) {
|
||||
if (element.getType() == Element.e_text) {
|
||||
GState gState = element.getGState();
|
||||
boolean isTextVisible = isTextRenderedVisibly(gState);
|
||||
if (!isTextVisible) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private void processImages(Element imageElement, ElementWriter writer, InvisibleElementRemovalContext context) throws PDFNetException {
|
||||
|
||||
Rect rect = imageElement.getBBox();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user