How can I identify invisible/hidden objects on a PDF page?

Q: We are attempting to write a system which requires us to use lines,
rectangle etc. (path objects). We need an effective way it discount
invisible objects. I under that to do this 100% correctly would be a
complicated algorithm do to clipping, layering and contrasting
colours/opacity. However are there easy flags/value associated with
these objects which the majority of authoring tools use to create
invisible lines to be invisible? We noticed that some document (I
guess from MS Excel) use "device colour grey" which sometimes but not
always seems to be set with invisible lines.

If you could give us some pointers into how to do this it would be
greatly appreciated.

There is no perfect way (or rule) to detect invisible objects in PDF.

I guess you could start by checking for the following properties on
graphical elements:
  - bounding box (not empty)
  - intersection with the parent clip box (not empty)
  - opacity (not 0)
  - Is the path element, a clipping path?
  - TextRenderMode (if element is text)
  - ...

The bulletproof implementation would probably be quite complex, but
looking for the above attributes may be a good starting point.