我想知道是否有任何方法使用 Tika/Python 仅解析第一页或仅从第一页提取元数据?现在,当我传递 pdf 时,它正在解析每一页。我看了这个链接:Is it possible to extract text by page for word/pdf files using Apache Tika? 但是,此链接在我不熟悉的 java 中解释了更多内容。我希望有一个python解决方案吗?谢谢!
from tika import parser
# running: java -jar tika-server1.18.jar before executing code below.
parsedPDF = parser.from_file('C:\\path\\to\\dir\\sample.pdf')
fulltext = parsedPDF['content']
metadata_dict = parsedPDF['metadata']
title = metadata_dict['title']
author = metadata_dict['Author'] # capturing all the names from lets say 15 pages. Just want it to capture from first page
pages = metadata_dict['xmpTPg:NPages']