Revisions
-
Samathy created this gist
Jan 5, 2018 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ 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()): #print("========= PAGE {} =========".format(i+1)) page = doc.page(i) annotations = page.annotations() (pwidth, pheight) = (page.pageSize().width(), page.pageSize().height()) if len(annotations) > 0: for annotation in annotations: if isinstance(annotation, popplerqt4.Poppler.Annotation): total_annotations += 1 if(isinstance(annotation, popplerqt4.Poppler.HighlightAnnotation)): quads = annotation.highlightQuads() txt = "" for quad in quads: rect = (quad.points[0].x() * pwidth, quad.points[0].y() * pheight, quad.points[2].x() * pwidth, quad.points[2].y() * pheight) bdy = PyQt4.QtCore.QRectF() bdy.setCoords(*rect) txt = txt + str(page.text(bdy)) + ' ' #print("========= ANNOTATION =========") print(txt) if total_annotations > 0: print (str(total_annotations) + " annotation(s) found") else: print ("no annotations found") if __name__ == "__main__": main()