Reputation: 11
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
Upvotes: 1
Views: 219
Reputation: 135
def pdfs():
pdf = pikepdf.open("/full/path/to/pdf.pdf")
docinfo = pdf.docinfo
for key, value in docinfo.items():
print(key, ":", value)
Output:
/Producer : Name
/Title : Another name
Here's the documentation as well: https://buildmedia.readthedocs.org/media/pdf/pikepdf/latest/pikepdf.pdf
Upvotes: 1