How to select certain keys and corresponding values using docinfo.items() in pikepdf (python) during extraction of metadata

Viewed 39

I am trying this code to extract metadata for a pdf There is author and then title, I want values for only author and title from the metadata ''' import pikepdf pdf = pikepdf.open(path) docinfo = pdf.docinfo for key, value in docinfo.items(): if str(key).startswith("A") == True or str(key).startswith("Ti") == True: print(key, ":", value) '''
The code runs but gives no output

1 Answers
Related