title: Extracting text from highlighted annotations in a PDF file
body: <p>Since yesterday I'm trying to extract the text from some highlighted annotations in one pdf, using python-poppler-qt4.</p>
  
  <p>According to <a href="http://people.freedesktop.org/~aacid/docs/qt4/classPoppler_1_1Page.html" rel="nofollow noreferrer">this documentation</a>, looks like I have to get the text using the Page.text() method, passing a Rectangle argument from the higlighted annotation, which I get using Annotation.boundary(). But I get only blank text. Can someone help me? I copied my code below and added a link for the PDF I am using. Thanks for any help!</p>
  
  <pre><code>import popplerqt4
  import sys
  import PyQt4
  
  
  def main():
  
      doc = popplerqt4.Poppler.Document.load(sys.argv[1])
      total_annotations = 0
      for i in range(doc.numPages()):
          page = doc.page(i)
          annotations = page.annotations()
          if len(annotations) &gt; 0:
              for annotation in annotations:
                  if  isinstance(annotation, popplerqt4.Poppler.Annotation):
                      total_annotations += 1
                      if(isinstance(annotation, popplerqt4.Poppler.HighlightAnnotation)):
                          print str(page.text(annotation.boundary()))
      if total_annotations &gt; 0:
          print str(total_annotations) + " annotation(s) found"
      else:
          print "no annotations found"
  
  if __name__ == "__main__":
      main()
  </code></pre>
  
  <p>Test pdf:
  <a href="https://www.dropbox.com/s/10plnj67k9xd1ot/test.pdf" rel="nofollow noreferrer">https://www.dropbox.com/s/10plnj67k9xd1ot/test.pdf</a></p>