How can i detect if an element is hidden in the pdf?

I´m trying export the vectors and graphics in two diferents images, but I have a problem with this.

How can i detect if an text-element is hidden ?
e.g. discard an text element if an image is over that element, maybe detecting the layer-number or z-index of the element.

I´m develop in c++

psudocode:

while ((element = reader.Next()) != 0)
{
if(element.GetType()==Element::e_text){

if(this_element_is_below==true)continue;

}

Thank you.
Best regards,
Emmanuel García.