Document visible content

Hi support,

I’m trying to find a way to check if my document has any visible content in its body. For example, I search within the paragraphs collection for text, if there is any non-empty content within the text’s segments. But it works if I have only texts elements in the document : the cast from PdfElementBase to Text works. But I might have tables, or any other type of elements, and I cannot cast, because I do not know the type of the PdfElementBase.

Here is a sample :

for(int i = 0; i < firstSection.getParagraphs().size(); ++i)
{
PdfElementBase element = firstSection.getParagraphs().get(i);
Text text = (Text) element;
if(text != null)
{
for(int x = 0; x < text.getSegments().size(); ++x)
{
Segment seg = text.getSegments().getAt(x);
if(!seg.getContent().isEmpty())
{
textHasContent = true;
break;
}
}
if(textHasContent)
{
break;
}
}
}

Please advice,
Milan

Hi support,

I’ve found that section.getParagraphs().get(index).getDOMElement().getNodeName() returns the type of that paragraph : “Table”, “Text” etc. Is there any other solution ?

Milan

Hi support,

Can you please update the status of this thread ?

Thank you,
Milan

Hello Milan,

Sorry for getting back to you so late.

We are working over this issue and will update you with the status, shortly.

Please accept our humble apologies for the inconvenience that you have been facing.

Hi Milan,

Sorry for replying to you so late because of the holiday in China. I think the getNodeName()can help you to check the visible content. We have not found other solution.