How to retrieve specific text (like comments) from pdf or docx?

Certified Senior Developer

I have file(docx,pdf) and i have to retrieve or extract comments from the that.

  Discussion posts and replies are publicly visible