如何使用pikepdf(python)中的docInfo.items()在提取元数据中选择某些键和相应值
我正在尝试此代码以提取PDF的元数据 有作者,然后是标题,我只想要作者的价值,而元数据的标题 ''' 导入PikePDF
pdf = pikepdf.open(path)
docinfo = pdf.docinfo
对于键,docinfo.items中的值():
如果str(key).startswith(“ a”)== true或str(key).startswith(“ ti”)== true:
print(键,“:”,value)
'''
代码运行但没有输出
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
输出:
/制作人:名称
/标题:另一个名称
也是文档: https://buildmedia.readthedocs.org/media/pdf/pikepdf/latest/pikepdf.pdf
Output:
/Producer : Name
/Title : Another name
Here's the documentation as well: https://buildmedia.readthedocs.org/media/pdf/pikepdf/latest/pikepdf.pdf