view pdfComments.py @ 15:22b0894c0f4c

fixed Column.updateHeader wrt 5a, but broke it wrt C0 and missing red for R2
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Sun, 22 Mar 2020 18:15:42 +0000
parents e07789816ca5
children
line wrap: on
line source

import PyPDF2 as pyPdf, sys

if sys.argv[1]=='-v':
    verbose=True
    sys.argv.pop(1)
else:
    verbose=False

f = open(sys.argv[1],'rb')

pdf = pyPdf.PdfFileReader(f)
pgs = pdf.getNumPages()
key = '/Annots'
uri = '/URI'
ank = '/A'

#print pdf.getNamedDestinations()

for pg in range(pgs):
    print '#',pg
    p = pdf.getPage(pg)
    o = p.getObject()
    #print o.keys()
    if o.has_key(key):
        ann = o[key]
        #print key,ann
        for a in ann:
            u = a.getObject()
            if '/Contents' in u:
                print "%s: %s"%(u['/Subtype'],u['/Contents'])