본문 바로가기
파이썬

파이썬 Python에서 PDF 속성 / 메타 데이터 읽기

by º기록 2021. 1. 29.
반응형

Python을 사용하여 PDF 파일에 저장된 제목, 저자, 주제 및 키워드와 같은 속성 / 메타 데이터를 어떻게 읽을 수 있습니까?

 

해결 방법

 


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'}]


 

참조 페이지 https://stackoverflow.com/questions/14209214

 

 

반응형

댓글