mybin

my ~/bin
git clone https://a3nm.net/git/mybin/
Log | Files | Refs | README

pdfdump (501B)


      1 #!/usr/bin/env python3
      2 
      3 # https://stackoverflow.com/a/54823050
      4 # by https://stackoverflow.com/users/2747626/mxl
      5 
      6 import sys
      7 import PyPDF2, traceback
      8 
      9 src = sys.argv[1]
     10 
     11 input1 = PyPDF2.PdfFileReader(open(src, "rb"))
     12 nPages = input1.getNumPages()
     13 
     14 for i in range(nPages) :
     15     page0 = input1.getPage(i)
     16     try :
     17         for annot in page0['/Annots'] :
     18             print (annot.getObject())       # (1)
     19             print ('')
     20     except : 
     21         # there are no annotations on this page
     22         pass
     23