如何使用Python读取存储在PDF文件中的属性/元数据(如标题,作者,主题和关键字)?
试试pdfminer:
from pdfminer.pdfparser import PDFParser
from pdfminer.pdfdocument import PDFDocument
fp = open('diveintopython.pdf', 'rb')
parser = PDFParser(fp)
doc = PDFDocument(parser)
print(doc.info) # The "Info" metadata
这是输出:
>>> [{'CreationDate': 'D:20040520151901-0500',
'Creator': 'DocBook XSL Stylesheets V1.52.2',
'Keywords': 'Python, Dive Into Python, tutorial, object-oriented, programming, documentation, book, free',
'Producer': 'htmldoc 1.8.23 Copyright 1997-2002 Easy Software Products, All Rights Reserved.',
'Title': 'Dive Into Python'}]
有关更多信息,请看本教程:一个轻量级的XMP解析器,用于在Python中提取PDF元数据。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句